I'm trying to write a program that involves comparing chars as part of a menu system for a program that decodes resistor codes. At the end of the menu it asks if you want to decode another resistor, repeating the program if the user selects "yes".
This is the code I have so far:
//used for repeating input menu
int menu = 0;
char menuChoice = 0;
//rest of program goes here
printf("Do you want to decode another resistor? (y/n)");
scanf("%c", &menuChoice);
while(menuChoice != "y" && menuChoice != "Y" && menuChoice != "n" && menuChoice != "N")
{
if(menuChoice != "Y" && menuChoice != "y")
{
if(menuChoice == "N" || menuChoice == "n")
{
menu = 0;
}
else
{
printf("Invalid choice.");
}
}
}
When I try to compile with GCC, I end up with a warning that says "comparison between pointer and integer." Since scanf only accepts a pointer, I don't know how exactly to compare the scanned char with to "Y" or "n". Is there something I'm missing here?