Re: never ending loop

From: J.P. (J.P_at_provider.net)
Date: 10/29/03

  • Next message: Jack Klein: "Re: Read single char from input including the whitespace"
    Date: Wed, 29 Oct 2003 00:02:55 +0100
    
    

    "Josh Sebastian" <curien@cox.net> wrote in message
    news:pan.2003.10.28.22.55.25.408819@cox.net...
    > On Tue, 28 Oct 2003 23:22:34 +0100, J.P. wrote:
    >
    > >
    > > "Artie Gold" <artiegold@austin.rr.com> wrote in message
    > > news:3F9EE4D1.6030600@austin.rr.com...
    > > <Some code>
    > >
    > >> See:
    > >>
    > >> http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.2
    > >>
    > >> (you must have missed it when you read the C++ FAQ before posting)
    > >
    > > Thanks for the link, but I hate the solution (reading a variable in the
    > > 'while'). I will read faq-15.3.
    >
    > Reading it in the while is idiomatic (meaning it's what C++ programmers
    > are used to seeing), so using a different technique may reduce the
    > readability of your code. But in any case, all it does is avoid repeated
    > code. The technique is generally called a "priming read", and I first
    > learned to do it in Pascal. Without the idiom, it looks like
    >
    > cin >> x;
    > while(!cin.good()) {
    > cin.ignore(...);
    > cin.clear();
    > cin >> x;
    > }
    >
    > You see how we had to write cin >> x twice? Putting it in the while avoids
    > that, and that's a Good Thing(tm).

    Yes, I see. Still hate it for now. It will probably change when I do this
    more often. My programming-teacher at school would have killed me if I did
    this in Modula-2.

    --
    J.P.
    

  • Next message: Jack Klein: "Re: Read single char from input including the whitespace"

    Relevant Pages

    • Re: A Teacher Grows Disillusioned After a Fail Becomes a Pass
      ... Unfortunately, Alvin, that's the ONLY criticism that can be properly levied against the schools. ... On what basis do you make the claim that the technique is failing? ... One of his conclusions from the study is that anyone who goes to school intuitively assumes they are as qualified as anyone else to discuss pedagogy, that the quality of education that they were served by their school is assumed to be a "gold standard" that all others must aspire to, and any failure on their part to have not succeeded is assumed to be their own fault for not working harder or behaving properly. ... Up to that time, parents believed that if their kids didn't succeed in school, they didn't succeed because their kids weren't studying sufficiently. ...
      (soc.retirement)
    • Re: A Teacher Grows Disillusioned After a Fail Becomes a Pass
      ... Unfortunately, Alvin, that's the ONLY criticism that can be properly levied against the schools. ... On what basis do you make the claim that the technique is failing? ... One of his conclusions from the study is that anyone who goes to school intuitively assumes they are as qualified as anyone else to discuss pedagogy, that the quality of education that they were served by their school is assumed to be a "gold standard" that all others must aspire to, and any failure on their part to have not succeeded is assumed to be their own fault for not working harder or behaving properly. ... These all factor in, he concludes, as to why quality discussions on education are so difficult to have. ...
      (soc.retirement)
    • Re: A Teacher Grows Disillusioned After a Fail Becomes a Pass
      ... Unfortunately, Alvin, that's the ONLY criticism that can be properly ... On what basis do you make the claim that the technique is failing? ... One of his conclusions from the study is that anyone who goes to school ... due to the parents insistence that the ...
      (soc.retirement)
    • Re: MA for young kids
      ... Kids love wrastle'n around. ... getting him into a school teaching a more ideal version of the art. ... technique at all of their schools. ...
      (rec.martial-arts)
    • Re: A Teacher Grows Disillusioned After a Fail Becomes a Pass
      ... Unfortunately, Alvin, that's the ONLY criticism that can be properly levied against the schools. ... On what basis do you make the claim that the technique is failing? ... One of his conclusions from the study is that anyone who goes to school intuitively assumes they are as qualified as anyone else to discuss pedagogy, that the quality of education that they were served by their school is assumed to be a "gold standard" that all others must aspire to, and any failure on their part to have not succeeded is assumed to be their own fault for not working harder or behaving properly. ... Up to that time, parents believed that if their kids didn't succeed in school, they didn't succeed because their kids weren't studying sufficiently. ...
      (soc.retirement)