0

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?

2
  • Having the code might help debugging
    – Blauelf
    Commented Mar 9, 2017 at 6:57
  • Are you including the libraries correctly? Are you including the CS50 library? Commented Mar 10, 2017 at 1:13

1 Answer 1

0

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.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .