I have a code snippet that I am using to learn some C
char* input( char *s ){
scanf("%[^\n]%*c",s);
return s;
}
void main()
{
printf("Welcome to a string input/output example written in C! \n");
printf("Type e to exit \n");
printf(" \n");
while (0 == 0){
printf("> ");
char str[100];
input( str );
//All off this code works perfectly until the switch statement, which apparently cannot recognized the 'e' case:
switch(str){
case 'e' : break;
default : printf("Your string is: %s \n", str);
}
}
}
However, when this code is run it returns the string fine, however during the switch statement it default to the default and even if the value of "str" is "e", it returns:
Your string is: e
instead of exiting. Please help this is very strange..