int strcmp ( const char * string1, const char * string2 );
Compare two strings.
Compares string1 to string2 character by character.
This function starts comparing the first character of each string. If they are equal to each other continues with the following pair until the characters differ or until end of string is reached.
Returns a value indicating the lexicographical relation between the strings:
return value description <0 string1 is less than string2 0 string1 is the same as string2 >0 string1 is greater than string2
Defined in ANSI-C.
/* strcmp example */
char szKey = "apple";
printf ("Which is my favourite fruit? ");
} while (strcmp (szKey,szInput) != 0);
printf ("Correct answer!\n");
Which is my favourite fruit? orange
Which is my favourite fruit? apple
strncmp, strrchr, strspn, memcmp