Need help with comparing strings (I'm a beginner C programmer)
I'm very new to C programming. My only other programming experience is Python Programming. I have an assignment in my programming class that involves comparison of strings, so I figured I'd write a little test program to see if I'm capable of doing that...
So far I've been unsuccessful.... I tried to compare two strings, but even if they appear exactly the same, my program doesn't seem to agree.
Here's the code...
And here's what my output looks like...
char* comp = "dummy";
printf("Enter a string: ");
printf("The string you entered is %s.\n", string);
printf("The string you are comparing to is %s.\n", comp);
if(string == comp)
printf("The strings match!\n");
printf("The strings don't match!\n");
I don't know what I'm doing wrong. >_< Can anyone help me?
Enter a string: dummy
The string you entered is dummy.
The string you are comparing to is dummy.
The strings don't match!