0
[C language] how to make loop until true?
Like.. I need to input monster type, it must be large, small, pets, or endemic. I want to make that if the type I input is other than the one of that four type, it will loop until the input is true.. Please, help me.. I put my code here : https://code.sololearn.com/cozPXDjjCVne/?ref=app
9 Antworten
+ 2
You chained the strcmp checks wrongly there I think. Try:
while(!(strcmp(...) == 0 || strcmp(...) == 0 || ...)) {
}
+ 2
`!=` is not the correct way to compare strings in c, that's why your code doesn't work. Have a look at the `strcmp` function!
if(strcmp(monster, "Large") == 0) {
//the strings are equal!
}
+ 2
Your way to loop until true is correct just use the strcmp method instead of != to compare it inside the while loop
+ 2
No, if the user inputs the correct value you expect then the loop will not execute.
+ 1
Arun Ruban SJ ok, thank you. So, i don't need to use ++ ?
+ 1
Arun Ruban SJ thanks :)
+ 1
Schindlabua it's work. Thanks
0
Schindlabua ok, thankyou. But, how to loop until true?
0
Arun Ruban SJ can you help me again? I already change my code, but it still not run
https://code.sololearn.com/cozPXDjjCVne/?ref=app