Okay, I'm reading C for dummies, and once again I am having scanf
problems. I wrote another questioner earlier with the similar problem but the fix will not work here. Every time I compile, gcc always says:
MADLIB1.C: In function ‘int main()’:
MADLIB1.C:19:27: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘char ()[20]’ [-Wformat]
MADLIB1.C:21:22: warning: format ‘%s’ expects argument of type ‘char’, but argument 2 has type ‘char ()[20]’ [-Wformat]
MADLIB1.C:23:23: warning: format ‘%s’ expects argument of type ‘char’, but argument 2 has type ‘char ()[20]’ [-Wformat]
MADLIB1.C:25:27: warning: format ‘%s’ expects argument of type ‘char’, but argument 2 has type ‘char (*)[20]’ [-Wformat]
MADLIB1.C:31:52: error: expected ‘}’ at end of input
Here's my code:
/*
MADLIBI.C Source Code
Written by Arshad Husain
*/
#include <stdio.h>
int main()
{
char adjective[20];
char food[20];
char chore[20];
char furniture[20];
/* Get the words to use in the madlib */
printf("Enter an adjective"); /* prompt */
scanf("%s",&adjective);
printf("Enter a food");
scanf("%s",&food);
printf("Enter a household chore (past tense):");
scanf("%s",&chore);
printf("Enter an item of furniture");
scanf("%s",&furniture);
/* Display the output */
printf("\n\nDon't touch that %s %s!\n", adjective, food);
printf("I just %s the %s!\n", chore, furniture);
return(0);
}