0

How Do I Correctly use strcmp to compare the array to user input ? (What's Wrong with my Code for text input!!)

My problem: It keeps saying the strcmp() function is undeclared. #include <stdio.h> //Playing a Game of Checkers.. int main() { char user_input[4]; printf("Are you Smart? [yes or no]\n"); scanf("%s", user_input); if (strcmp ("yes", user_input) == 0) { printf("Then Go left smarty-pants :*"); } if (strcmp ("no", user_input) == 0) { printf("Then play to the Right dummy"); } return (0); }

11th Jul 2021, 7:16 AM
Mwamba
2 Answers
+ 1
it's fine, that warning is just letting you know that you havent included the string header file. Try adding it at the top
11th Jul 2021, 7:30 AM
Slick
Slick - avatar
+ 1
Slick Thank you!!!
11th Jul 2021, 7:54 AM
Mwamba