Lecture quiz 9 Write a C program equivalent to one of the C programs in sections 1.5 of K&R. The programs are called file copying, character counting, line counting, word counting, and arrays. They are described on pages 15 to 24 of K&R (or see programs 10, 11 and 13 to 17 at http://www.temple.edu/stafford/cis2107f12/kandr/chap1/index.html #include int strcmp(char s[], char t[]); main() { char s[] = "This is the first string"; char t[] = "This is the second string"; printf("%d\n", strcmp(s, t)); } int strcmp(char *s, char *t) { for (; *s == *t; s++, t++) if (*s == '\0') return 0; return *s - *t; } #include int strcmp(char s[], char t[]); main() { char s[] = "This is the first string"; char t[] = "This is the second string"; printf("%d\n", strcmp(s, t)); } int strcmp(char *s, char *t) { int i; for (i = 0; *(s+i) == *(t+i); i++) if (*(s+i) == '\0') return 0; return *(s+i) - *(t+i); } #include int strcmp(char s[], char t[]); main() { char s[] = "This is the first string"; char t[] = "This is the second string"; printf("%d\n", strcmp(s, t)); } int strcmp(char *s, char *t) { while (*s == *t) { if (*s == '\0') return 0; s++, t++; } return *s - *t; } How to get intro trouble. 1. (*s == *t) != '\0' (*s == *t) && (*s != '\0') 2. (*s = *t) 3. while (*s++ == *t++) 4. while (++*s == ++*t) 5. return s - t;