void viewonechar(){
char name[25], c[25];
int n;
fp = fopen("Phonebook.txt","r");
printf ("\n\n Enter Character : ");
scanf ("%s",c);
fscanf (fp, "%s %d", name, &n);
while (!feof(fp)){
if ((strcmp(c, name[0])) == 0){ \\ Warning in here
printf (" %s +880%d\n",name, n);
}
fscanf (fp, "%s %d", name, &n);
}
printf ("\n\n");
fclose(fp);
menu();
}
When i compile the code, on the marked line this warning appears, "Passing argument 2 of strcmp makes pointer from integer without a cast". What exactly am i doing wrong?
nameis achar[25]array, what do you supposename[0]is ?strcpyrequires aconst char*for the second parameter;name[0]is not that.int. Thechartype (that is each array element) is an integer type.if (name[0] == c[0]) {...? Or all characters from c to the beginning of nameif (strncmp(c, name, strlen(c)) == 0) {...while (!feof(fp)){==>while (fscanf (fp, "%s %d", name, &n) == 2){and remove the two otherfscanfstatements. The loop is best controlled by testing for correct conversion.