Working on pset2: "initials.c" ... my code runs fine, outputting the expected initials when it opens with a statement such as string s = " John J Smith"; (which I used during programming to avoid constantly typing in input), but when I switch to string s = get_string(); and type in the same name, I get the (apparently infamous) "Segmentation fault." Same with or without the if(s != NULL) condition. Any ideas?
1 Answer
Turned out to be a garden-variety error in indexing: I had nested loops, and the inner exceeded the limit on the outer, since had only included a while i < x condition on the outer loop, but a couple of the inner loops had i++. (Still not sure why it only showed up with the user-provided input, though.)