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

12th Apr 2022, 4:57 AM
Vicent Roxan
Vicent Roxan - avatar
4 Antworten
+ 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; }
12th Apr 2022, 5:17 AM
Brian
Brian - avatar
+ 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.
12th Apr 2022, 5:37 AM
Brian
Brian - avatar
+ 2
Brian thanks
12th Apr 2022, 6:40 AM
Vicent Roxan
Vicent Roxan - avatar
+ 1
Brian what is EOF mean for?
12th Apr 2022, 5:22 AM
Vicent Roxan
Vicent Roxan - avatar