3.9. strncmp

int strncmp( const char *s1, const char *s2, size_t n);
strncmp compares at most n characters of string s1 to string s2, returns <0 if s1<s2, 0 if s1==s2, or >0 if s1>s2.

For example, to search stdin for lines starting with "int":

        while( fgets( line, BUFSIZ, stdin) != NULL)     /* read one line */
            if( strncmp( line, "int", 3) == 0)          /* check for match */
                fputs( line, stdout);