0
[SOLVED] Jungle Camping challenge
Can anyone explain why it dont work for case 5? And by the way, does anyone know how to take multiple inputs in C without using scanf("%s%s%s....",s1,s2,s3.....); ? https://code.sololearn.com/cOG3nZGVrBF3/?ref=app
4 Respuestas
+ 3
What you are looking for is implemented as a while loop. This is the answer to both questions.
#include <stdio.h>
int main() {
char s[6];
while (scanf("%s", s) != EOF) {
switch(s[0]){
case 'G':
printf("Lion");
break;
case 'R':
printf("Tiger");
break;
case 'S':
printf("Snake");
break;
case 'C':
printf("Bird");
break;
}
printf(" ");
}
return 0;
}
+ 3
Vicent Roxan EOF is a constant that is defined in stdio.h. It means End Of File. When scanf finds no more data in the input stream it returns EOF.
On Sololearn it is reading from an input file. On an interactive console you would have to press ctrl-z to indicate that you are done with entering input.
+ 2
Brian thanks
+ 1
Brian what is EOF mean for?