Currently At: Programming Reference > C Reference > Standard C String & Character > strcmp()

strcmp()


Syntax:
#include <string.h>
int strcmp( const char *str1, const char *str2 );


Description:
The function strcmp() compares str1 and str2, then returns:

Return value Explanation
------------ -----------
less than 0 str1 is less than str2
equal to 0 str1 is equal to str2
greater than 0 str1 is greater than str2


Example:
printf( "Enter your name: " );
scanf( "%s", name );
if( strcmp( name, "Mary" ) == 0 )
  printf( "Hello, Dr. Mary!\n" );


Related Topics:
memcmp(), strchr(), strcpy(), strncmp()


Web Standards & Support:

Link to and support eLook.org Powered by LoadedWeb Web Hosting
Valid XHTML 1.0! Valid CSS! eLook.org FireFox Extensions