strcmp
Compares two strings (function or macro)
#include <string.h> int strcmp ( const char *s1, const char *s2);
strcmp returns an integer less than, equal to, or greater than zero, indicating that the string pointed to by s1 is less than, equal to, or greater than the string pointed to by s2.
The strcmp function or macro compares the string pointed to by s1 to the string pointed to by s2.
#include <string.h> #include <stdio.h> main () { printf ("%d\n", strcmp ("abcdef", "abcdef") ); printf ("%d\n", strcmp ("abcdef", "abc") ); printf ("%d\n", strcmp ("abc", "abcdef") ); printf ("%d\n", strcmp ("abcdef", "mnopqr") ); printf ("%d\n", strcmp ("mnopqr", "abcdef") ); }
produces the following:
0 1 -1 -1 1