I am creating a menu that needs to take in an three inputs from the users.
char *fullname;
char *date;
float sal;
printf("\nEnter full name: ");
line92
scanf("%s", &fullname);
printf("\nEnter hire date: ");
Line 94
scanf("%s", &date);
printf("\nEnter salary: ");
Line 96
scanf("%d", &sal);
These are the errors I am recieving
Employee.c:92: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char **’
Employee.c:94: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char **’
Employee.c:96: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘float *’
Can I get an explanation of what is causing these issues?
There are several problems:
First:
When you use
scanffor strings you do not use the&. So justscanf("%s", fullname);.Second:
Your pointers aren’t initialized. Try this instead:
This will work as long as you input at most 255 characters.
Third:
Your typing for the last
scanfdoesn’t match. You’re passing in afloatwhen you’ve specified anintin the format string. Try this: