char * read_command()
{
char command[25];
char *input = malloc(sizeof(char) * 25);
printf("myRolodex Command: ");
scanf("%c", &command);
strcpy(input, command);
return input;
}
void evaluate_command(char command[250])
{
if (strcmp(command == 'I')==0)
{
printf("\nenterned i");
}
}
int main()
{
evaluate_command(read_command))
return 0;
}
I've tried doing this but i get when compiling:
rolodex.c: In function ‘read_command’:
rolodex.c:25: warning: format ‘%c’ expects type ‘char *’, but argument 2 has type ‘char (*)[25]’
rolodex.c: In function ‘evaluate_command’:
rolodex.c:32: warning: comparison between pointer and integer
rolodex.c:32: warning: passing argument 1 of ‘strcmp’ makes pointer from integer without a cast
/usr/include/string.h:143: note: expected ‘const char *’ but argument is of type ‘int’
rolodex.c:32: error: too few arguments to function ‘strcmp’
rolodex.c: In function ‘main’:
rolodex.c:43: warning: passing argument 1 of ‘evaluate_command’ from incompatible pointer type
rolodex.c:30: note: expected ‘char *’ but argument is of type ‘char * (*)()’
rolodex.c:43: error: expected ‘;’ before ‘)’ token
rolodex.c:43: error: expected statement before ‘)’ token
im supposed to be making "read_command can print a prompt, then read a character from the user. It may want to ensure the command is a valid command before returning it.
evaluate_command can take a command character and decide which command it is, then do the appropriate action."