Louis93
Louis93

Reputation: 3923

Why exactly is this error occurring when the loop executes to completion and how do I stop it?

Code: http://pastie.org/1966795

Trackback: http://pastie.org/1966799

TXT File I'm using: http://pastie.org/1966800

Keep in mind the program runs, my only issue is that it displays an error message at the end (see: trackback), that I don't know how to fix.

Upvotes: 0

Views: 70

Answers (2)

Louis93
Louis93

Reputation: 3923

This is the piece of code that fixed it. I caught the error within the main function. It seems a bit choppy to me, but it runs. If anyone of you see this and have a more elegant solution, I'm all ears.

http://pastie.org/1969148

I use slang in my code to pique interest haha sorry if it offends. It's not NSFW, no worries.

Upvotes: 0

NPE
NPE

Reputation: 500703

The problem happens when print_et_list is executing for the fourth time. By then you're past the end of your input file, so readline keeps returning empty strings. You should return from print_et_list early if question is blank, and correctly handle this case in main.

Upvotes: 2

Related Questions