Well, I am learning the C program. When I wrote a command I got an error message but I don't know why. The code runs like this:-
if (answer == "something")
[here, the 'answer' is a string variable]
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.
Sign up to join this communityWell, I am learning the C program. When I wrote a command I got an error message but I don't know why. The code runs like this:-
if (answer == "something")
[here, the 'answer' is a string variable]
You cannot compare strings in C to compare strings you must use a function called strcmp()
if I remember correctly it should be in the string.h so just #include <string.h>
and you should be able to use it.
If both strings are identical it should return 0, if not then the strings are not equal.