So, I am here again with another question. I am doing more of my C programming book exercises and i'v run into a snag. Right now I get the following error::
expected `;' before "int"
in function `int main()`:
`menu' cannot be used as a function
`menu' cannot be used as a function
I figure it's probably something stupid I missed. But i'v gone over every line like 4 times, and I still can't find it. Here's what i'v got so far.
Code:
#include <stdio.h>
#include <ctype.h>
int menu(void);
int song(void);
int show(void);
int main(void)
{
int choice;
int menu;
choice = menu(); /* get user's first selection */
while(choice != QUIT)
{
switch(choice)
{
case '1': show();
break;
case '2': song();
break;
default: printf("Oops! An invalid choice slipped through. ");
printf("Please try again.\n");
}
choice = menu(); /* get user's subsequent selections */
}
printf("Bye bye!\n");
printf("Press Enter to end the program.\n");
fflush(stdin);
getchar();
return 0;
}
int menu(void)
{
int option;
printf("Learn more about me! Please select from the menu.\n");
printf("1. Learn the name of my favorite show!\n2. Learn the first 4 lines of my favorite song!\n");
printf("Type Quit, to quit the Program!\n");
printf("Please enter the choice you wish to make:\n");
while( (scanf(" %d", &option) != 1) /* non-numeric input */
|| (option < 0) /* number too small */
|| (option > 2)) /* number too large */
{
fflush(stdin); /* clear bad data from buffer */
printf("That selection isn't valid. Please try again.\n");
printf("Your choice? ");
}
return option;
}
void song(void)
{
printf("Do you remember standing on a broken field\n");
printf("White crippled wings beating the sky\n"):
printf("The harbingers of war with their nature revealed\n");
printf("And our chances flowing by\n");
}
void show(void)
{
printf("Big Bang Theory // Two And A Half Men\n");
}
Thanks for any help you can provide.