strcmp()
should work just fine in this case. if it doesn't then
name
and what
*p
point to
are different. Remember that
strcmp()
does not return true if the case is different (e.b. "Hello" is not equal to "hello") and it does not return true for substrings (e.g. "Hello" is not equal to "Hello world")
What happens if you do
printf("name = \"%s\"\n", name);
printf("*p = \"%s\"\n", p);
printf("strcmp(name, p) = %d\n", strcmp(name, p));
if name and *p are equal, you should get a value of 0 for strcmp. If they are not equal, it should show up in the printfs. Perhaps you have trailing spaces or a trailing '\n' if you're getting input from a file or keyboard.