cmp2s.c (454B)
1 /* Exercise 8.9 */ 2 3 #include <stdio.h> 4 #include <string.h> 5 6 int main(void) 7 { 8 char s1[10]; 9 char s2[10]; 10 int val; 11 12 printf("Give me a string (s1): "); 13 gets(s1); 14 printf("Give me another string (s2): "); 15 gets(s2); 16 17 val = strcmp(s1, s2); 18 printf("s1 is "); 19 20 if(!val) 21 printf("equal to"); 22 else if(val < 0) 23 printf("less then"); 24 else 25 printf("greater then"); 26 27 printf(" s2\n"); 28 29 return 0; 30 } /* E0F main */ 31