struct phone
{
char fname[20];
char lname[20];
char pnumber[20];
};
int main()
{
int x=0;
int n;
char s[100];
FILE * f;
f = fopen("phone book","r");
if (f != NULL)
{
printf("file exist !\n");
while(!(feof(f)))
{
fscanf(f,"%s,%s,%s",s[x].fname,s[x].lname,s[x].pnumber);
x++;
}
}
printf("1- add");
printf("2- query");
scanf("%d",&n);
if(n==1)
printf("%s",s[n].fname);
if(n==2)
fclose(f);
}
I write this program and there is a problem in fscanf
the comment for the error
'main':|
request for member 'fname' in something not a structure or union|
request for member 'lname' in something not a structure or union|
request for member 'pnumber' in something not a structure or union|
request for member 'fname' in something not a structure or union|
: variable 's' set but not used [-Wunused-but-set-variable]|
: control reaches end of non-void function [-Wreturn-type]|
||=== Build finished: 4 errors, 2 warnings (0 minutes, 0 seconds) ===|