I have no idea why, but I'm having problems with getting my strings to compare properly. Below is my code. The part I'm having trouble with is in the while loop. For some reason the programs looping even when my string matches the constant. Any help would be appreciated.
//string constants for nicks, rays, mikes
const char *nicks = "nicks";
const char *rays = "rays";
const char *mikes = "mikes";
char* allLower(char*);
char* allLower(char* name)
{
int i = 0;
while(name[i] != '\0')
{
name[i] = tolower(name[i]);
++i;
}
printf("%s",name);
return name;
}
int main(){
char tempstring[20];
char* pizza_establishment;
int number_of_pizza_eaters;
char pizza_type[17];
printf("Which pizza place did you visit today? \nNicks, Rays, or Mikes?");
fgets(tempstring,10,stdin);
pizza_establishment = allLower(tempstring);
printf("%s", pizza_establishment);
while((pizza_establishment != nicks) || (pizza_establishment != rays) || (pizza_establishment != mikes)){
printf("Error while entering restaurant name. Make sure you entered the name correctly.");
printf("Which pizza place did you visit today? \nNicks, Rays, or Mikes?");
fgets(pizza_establishment,10,stdin);
}
return( EXIT_SUCCESS );
}