+ 4
C - verify fgets in some possibilities
const char *test[4] = {"one", "two", "three"}; fgets(my_str, 10, stdin); how can I check if my_str == "one" or "two" or "three" but not like that : ? if my_str=="one" || my_str=="two"...
3 Respuestas
+ 6
Hi NoxFly ドリアン here try strcmp (http://www.cplusplus.com/reference/cstring/strcmp/) but remember fgets doesn't remove the "\n" from the buffer, so you have to clean it up manually, if you don't it will make comparison always wrong because of the "\n" 😁
+ 4
thanks I'll try :D
+ 2
you can do this loop, length of array is small. Either you can use sorting.