#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int outcome, len, l1, l2;
char *str = "asdf";
char *str1 = "asdfasdf";
/* find the length of shortest string */
l1 = strlen(str);
l2 = strlen(str1);
len = l1 < l2 ? l1:l2;
outcome = memcmp(str, str1, len);
if(!outcome)
printf("Equal");
else if(outcome<0)
printf("First less than second.");
else
printf("First greater than second.");
return 0;
}
|