Code:This is what I have so far
#include "stdafx.h"
#define QUIT 0
#define SHOW 1
#define SONG 2
int menu(void) ;
void song(void);
void show(void);
int _tmain(int argc, _TCHAR* argv[])
{
int choice;
choice = menu(); /* get user's first selection */
while("choice != QUIT");
{
switch(choice)
{
case SHOW:show();
break;
case SONG: 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!\n");
printf("Please select from the menu.\n");
printf("Enter 1 to learn the name of my favourite show.\n");
printf("Enter 2 to learn the first line of my favouite song.\n");
printf("Enter 0 to quit this program.\n") ;
printf("Please enter your choice:.\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("Sunny days seem to hurt the most. \n");
}
void show(void)
{
printf("SportsCentre. \n");
}
The problem is when it runs and i enter 1 or 2 nothing appears even 0 to quit nothing. Ive been told that while("choice != QUIT"); is an error and my case statements are wrong but i have no idea how to fix them Thanks