Discussion:
Use of goto statements (especially in A4Q1)
(too old to reply)
Timothy Ko
2011-07-04 20:38:46 UTC
Permalink
Since it's not structured programming to use goto statements, are we not
supposed to use them?

Also in A4Q1, I have a ton of "if in.fail, then see if it's end of file,
if not then print error message" because of all the times I have to read
the next character. Since I have to break out of the loop for EOF (or
return), I can't use a helper, so it's really cluttering my code. Is
there a way to fix this without goto statements?

Thanks,
Tim
Terry Anderson
2011-07-04 21:18:07 UTC
Permalink
Goto is acceptable to use in certain circumstances (refer to the course
notes), but the way you describe here does not sound like such a
circumstance.

Because your question is extremely specific to your particular solution,
the newsgroup is not the best place for this discussion. Send an email
to a member of the course staff (with your code attached) so we can see
the approach you're taking, and we can offer some direction.
--
Terry Anderson
CS 246 Instructor
Post by Timothy Ko
Since it's not structured programming to use goto statements, are we not
supposed to use them?
Also in A4Q1, I have a ton of "if in.fail, then see if it's end of file, if
not then print error message" because of all the times I have to read the
next character. Since I have to break out of the loop for EOF (or return), I
can't use a helper, so it's really cluttering my code. Is there a way to fix
this without goto statements?
Thanks,
Tim
Loading...