#include int strcmp( char s1[], char s2[] ) { /* ---------------------------------- '\0' marks the end of the string ! ---------------------------------- */ while ( *s1 != '\0' && *s2 != '\0' && *s1 == *s2 ) { s1++; s2++; } return *s1 - *s2; } int main(int argc, char *arg[]) { char a[] = "Hell"; char b[] = "Hello"; char c[] = "Hellx"; printf("strcmp(%s, %s) = %d\n", b, b, strcmp(b, b) ); printf("strcmp(%s, %s) = %d\n", b, a, strcmp(b, a) ); printf("strcmp(%s, %s) = %d\n", b, c, strcmp(b, c) ); }