Visual C++ 6.0 Runtime Error

Discussion in 'C++' started by =?iso-8859-1?q?Drag=F3nChristiano?=, Nov 13, 2006.

  1. The following code doesn't appear to run correctly compiled with Visual
    C++ 6.0. I haven't gotten a chance to try this in GCC yet. "A" is
    never output, not even on the first iteration. I have heard of
    something called a stacking error, could someone please explain this to
    me?

    while(infile>>c){
    cout << "A";
    while(flag){
    cout << "B";
    if(isalpha(c)){
    total++;
    } else {
    flag=false;
    }
    }
    words++;
    flag=true;
    }
     
    =?iso-8859-1?q?Drag=F3nChristiano?=, Nov 13, 2006
    #1
    1. Advertising

  2. =?iso-8859-1?q?Drag=F3nChristiano?=

    Marcus Kwok Guest

    DragónChristiano <> wrote:
    > The following code doesn't appear to run correctly compiled with Visual
    > C++ 6.0. I haven't gotten a chance to try this in GCC yet. "A" is
    > never output, not even on the first iteration. I have heard of
    > something called a stacking error, could someone please explain this to
    > me?
    >
    > while(infile>>c){
    > cout << "A";
    > while(flag){
    > cout << "B";
    > if(isalpha(c)){
    > total++;
    > } else {
    > flag=false;
    > }
    > }
    > words++;
    > flag=true;
    > }


    I don't know what you mean by "stacking error", but please see the
    following FAQ:

    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8

    --
    Marcus Kwok
    Replace 'invalid' with 'net' to reply
     
    Marcus Kwok, Nov 13, 2006
    #2
    1. Advertising

  3. DragónChristiano wrote:
    > The following code doesn't appear to run correctly compiled with
    > Visual C++ 6.0.


    Your post falls under FAQ 5.8.

    > I haven't gotten a chance to try this in GCC yet.
    > "A" is never output, not even on the first iteration. I have heard of
    > something called a stacking error, could someone please explain this
    > to me?


    I don't know what that is, sorry.

    Have you tried debugging (stepping through) your program?

    >
    > while(infile>>c){
    > cout << "A";


    Try adding a nudge:

    cout << "A" << flush;

    > while(flag){


    BTW, what's the value of 'flag' the first time around?

    > cout << "B";


    Maybe even add 'flush' here too.

    > if(isalpha(c)){
    > total++;
    > } else {
    > flag=false;
    > }
    > }
    > words++;
    > flag=true;
    > }


    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Nov 13, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Polo Lee
    Replies:
    0
    Views:
    2,734
    Polo Lee
    Jul 7, 2003
  2. Mike Wahler
    Replies:
    3
    Views:
    979
    Noah Roberts
    Aug 12, 2003
  3. Hal Vaughan
    Replies:
    11
    Views:
    1,130
    Gordon Beaton
    May 22, 2006
  4. jonny
    Replies:
    1
    Views:
    469
    Michael Nemtsev
    Oct 6, 2007
  5. Replies:
    1
    Views:
    128
    Brian Palmer
    Jan 20, 2005
Loading...

Share This Page