// $Id: cmp_string.c,v 1.2 2009/09/08 01:44:01 joe Exp joe $ // eecs337 homework #1 // Joe Teagno (jrt32) #include #include #include int main(int argc, char* argv[]) { // we'll pack up our strings to make it easier to work with them typedef struct { char* a; // pointer to the first character of string a char* b; // likewise for string b } string_pair; // put the string pairs into an array so we can easily loop through them int string_pairs_length = 4; string_pair string_pairs[string_pairs_length]; string_pairs[0].a = "eecs"; string_pairs[0].b = "eecs"; string_pairs[1].a = "eecs"; string_pairs[1].b = "EECS"; string_pairs[2].a = "eecs"; string_pairs[2].b = "eec"; string_pairs[3].a = "eecs"; string_pairs[3].b = NULL; // notice that I'm declaring int i here, outside of the for loop. // when I try to declare i inside the for loop (as in "for (int i=0; ...") // gcc complains "error: ‘for’ loop initial declaration used outside C99 mode" // I don't know if this means that I'm not allowed to do this in C at all // (doubtful), or whether this construct wasn't made legal until // some later revision of C ("C99"?), and that I would need to set some // switch in gcc in order to allow it. int i; for (i=0; i