home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Teach Yourself C in 21 Days (6th Edition)
/
STYC216E.ISO
/
mac
/
Examples
/
Day10
/
Ex10_06.c
< prev
next >
Wrap
C/C++ Source or Header
|
2002-04-27
|
522b
|
33 lines
#include <stdio.h>
#include <string.h>
/* function prototypes */
char * compare_strings( char *, char *);
int main( void )
{
char *a = "Hello";
char *b = "World!";
char *longer;
longer = compare_strings(a, b);
printf( "The longer string is: %s\n", longer );
return 0;
}
char * compare_strings( char * first, char * second)
{
int x, y;
x = strlen(first);
y = strlen(second);
if( x > y)
return(first);
else
return(second);
}