home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C by Discovery (4th Edition)
/
C_By_Discovery_4th_Edition.tar
/
C_By_Discovery_4th_Edition
/
_DISK_
/
ch5
/
strcmps.c
< prev
next >
Wrap
C/C++ Source or Header
|
2005-06-16
|
889b
|
39 lines
/* strcmps.c
*
* Synopsis - Outputs the values returned by library
* function strcmp().
*
* Objective - To investigate the return value from
* strcmp().
*/
/* Include Files */
#include <stdio.h>
#include <string.h>
/* Constant Definitions */
#define LGTH 80
int main( void )
{
char string1[80];
char string2[80];
int result;
printf( "Enter the first string: " );
fgets( string1, LGTH, stdin );
printf( "Enter the second string: " );
fgets( string2, LGTH, stdin );
if ( ( result = strcmp( string1, string2 ) ) > 0 )
printf( "string1 > string2\n" );
else if ( result < 0 )
printf( "string1 < string2\n" );
else
printf( "string1 = string2\n" );
printf( "result is %d\n", result );
return 0;
}