#include #include #include // demonstrate some string library functions int main(int argc, char** argv) { char one[] = "rain"; char two[] = "raid"; char three[] = "rainy"; char four[10]; char five[35]; // print length of three and contents of three printf("there are %d characters in %s\n", strlen(three), three); // copy one into four strcpy(four,one); printf("one: %s four: %s\n", one, four); // strcmp returns 0 if they are equal, 0 is false, so this checks for equal if (!strcmp(one,four)) printf("%s == %s\n", one, four); else printf("%s != %s\n", one, four); // compare one ("rain") and three ("rainy") if (!strcmp(one,three)) printf("%s == %s\n", one, three); else if (strcmp(one, three) < 0) printf("%s < %s\n", one, three); else printf("%s > %s\n", one, three); // compare one ("rain") and two ("raid") if (!strcmp(one,two)) printf("%s == %s\n", one, two); else if (strcmp(one, two) < 0) printf("%s < %s\n", one, two); else printf("%s > %s\n", one, two); // copy one into five then concat two and three, then print strcpy(five, one); strcat(five, two); strcat(five, three); printf("five: %s\n", five); return (EXIT_SUCCESS); }