I've started learning C programming language recently. I wanted to write a simple yes/no program, however, there is an error in my code that I cannot seem to find a solution to.
Here is the code:
#include <stdio.h>
int main()
{
char answer[10];
printf("do you like programming? yes/no\n");
scanf(" %s", &answer);
if((answer == 'yes')|| (answer == 'no')){
printf("you are awesome\n");
}
else{
printf("try again\n");
}
return 0;
}
When I use y/n instead of yes/no, the program works fine. I know that I need to replace char with string, but I do not know how to do that. I read somewhere that I need to use a function called strcmp, but I do not know how to use that either. If anyone could help me, I would be really grateful.
Thanks in advance!