strcmp
Syntax:
#include <string.h> int strcmp( const char *str1, const char *str2 ); The function strcmp() compares str1 and str2, then returns:
For example: printf( "Enter your name: " ); scanf( "%s", name ); if( strcmp( name, "Mary" ) == 0 ) printf( "Hello, Dr. Mary!\n" ); Note that strcmp() does not perform bounds checking, and thus risks overrunning str1 or str2. For a similar (and safer) function that includes bounds checking, see strncmp(). |