Hey guys, this is one of my university exercises which I have a bit struggling with. It'd be great if you help me out with its coding :
Write a program for the management of a book of contacts of maximum 100 contacts.
The program shall allow the storage of following data in a structure:
typedef struct names {
char name[20];
char surname[20];
char number[20];
char mobile[20];
} Names;
The program shall allow the user to perform, by means of a menu, the input of a new contact (allowing eventual duplicates of name and surname, but shall give a warning to the user in case of duplicates and shall ask to confirm the input), and displays the complete list.
===
Update: I can't believe I didn't put my attempts in its following, I am sorry and I am definitely not putting my duties on somebody else shoulder :)
Anyway, this is my codes which I have been faced with many errors and I don't know exactly why!
Thanks for your considering :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100
typedef struct names {
char name[20];
char surname[20];
char number[20];
int mobile[20];
}Names;
int main()
{
int i;
Names n[20];
for(i=0;i<MAX;i++){
printf("Enter the name %d: ",i);
scanf("%s", n[i].name);
printf("Enter the surname %d: ",i);
scanf("%s", n[i].surname);
if((strcmp(n[i].name, n[i++].name)==0) && strcmp(n[i].surname, n[i++].surname==0)){
printf("Warning, There is another name the same!!!");
exit(1);
}
printf("Enter the mobile %d: ",i);
scanf("%d", &n[i].mobile);
}
for(i=1;i<MAX+1;i++){
printf("%d. %s %s: %d",n[i].name,n[i].surname,n[i].mobile);
}
return 0;
}