====== strcmp ====== #include //#include /* uncomment this for Windows */ int strcmp (const char *s1, const char *s) === Description === strcmp Compares 2 C strings. If both strings are identical, the return value of strcmp is 0. \\ If the string s1 less than s2, the return value is less than 0, \\ and s1 is greater than s2, then the return value greater than 0\\ ===== C Example Code ===== /* strcmp example code * http://code-reference.com/c/stdio.h/strcmp */ #include /* including standard library */ //#include /* uncomment this for Windows */ #include int main( void ) { char string1[5]="test"; char string2[6]="test2"; char string3[6]="test2"; /* string1 and string2 not compare */ if ( strcmp( string1, string2 ) == 0 ){ printf("same\n"); } else { printf("different\n"); } /* string1 and string2 not compare */ if ( strcmp( string2, string3 ) == 0 ){ printf("same\n"); } else { printf("different\n"); } return 0; } === Output of strcmp example === user@host:~$ ./strcmp different same