Re: How while loop works




Firstly, I would just like to point out that it's rarely a good idea to
use goto (in fact, I've never come across a good reason to use it in
"real" code).

But here, your reason for using it is to help to deepen your
understanding of C, and that's a pretty good reason, so let's look at
Many Many thanks Richard Heathfield for the explanation.I would like
tell you that I have seen use of goto in real code.It is a SNMP
protocol implementation. There for different condition one function
has to set error code in some specif structure and for some specific
error it has to set the value in some variable(structure) and continue
with in same function , for some error condition it simply return
error code and for successfull condition it has to set specific value
to specific structure.
I dont know if it could have been written in better way with out
goto .

But the code I posted purely to understand the while loop in C.
Thanks once again.

.



Relevant Pages

  • Re: address of a statement in C
    ... without a very good reason, ... <quote Go to Statement Considered Harmful, ... Dijkstra argues in favor of abolishing goto alltogether in higher level ... "The remark about the undesirability of the go to statement is far from new. ...
    (comp.lang.c)
  • Re: address of a statement in C
    ... The tone here is that the effects of using 'goto' aren't that much ... for both a theoretical reason and a practical reason. ... The theoretical reason is that 'goto' can lead to irreducible flow ... The practical reason is that programs using 'goto' are harder to ...
    (comp.lang.c)
  • Re: address of a statement in C
    ... However, there ren't many alternatives to printf, while there are ... many alternatives to goto. ... So there's a good reason to use a looping construct, ... The extra output could ...
    (comp.lang.c)
  • Re: New HIDE (HLA IDE) version is available
    ... > mistaken, but the reason, I think, was that in some rare cases the ... > return a non null error code. ... See, right now you're considering that a return-value of 1 is success, ... happened with dirty written apps that didn't return a proper value ...
    (alt.lang.asm)
  • kdelibs portupgrade prob
    ... This is one of the numerous kde* ports that fail to upgrade for 1 reason or ... *** Error code 1 ...
    (freebsd-stable)