Hi everyone!
i'm getting strange outputs for the following code.. can anyone explain the reason for such output?? :/
I use DEV c++
int color_choose(void) {
char clr[10]; int i;
/*enum {
green,aqua,red,purple,yellow,white
}a;*/
printf("\n\n\tText color can be changed here! This the list of available colors: ");
printf("\n\n\t Green\t Aqua\t Red\t Purple\t Yellow\t White\n\n\n");
printf("\t\t\t ENTER COLOR NAME: ");
fgets(clr,sizeof(clr),stdin);
for(i = 0 ; i <= sizeof(clr) ; i++) {
clr[i] = tolower(clr[i]);
}
if(strcmp(clr,"green") == 1)
printf("green");
if(strcmp(clr,"aqua") == 1)
printf("aqua");
if(strcmp(clr,"red") == 1)
printf("red");
if(strcmp(clr,"purple") == 1)
printf("purple");
if(strcmp(clr,"yellow") == 1)
printf("yellow");
if(strcmp(clr,"white") == 1)
printf("white");
system("pause");
}