Visual C++ 6.0 Runtime Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DragónChristiano

    #1

    Visual C++ 6.0 Runtime Error

    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;
    }

  • Victor Bazarov

    #2
    Re: Visual C++ 6.0 Runtime Error

    DragónChristian o 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


    Comment

    • Marcus Kwok

      #3
      Re: Visual C++ 6.0 Runtime Error

      DragónChristian o <bjbdragon@gmai l.comwrote:
      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:



      --
      Marcus Kwok
      Replace 'invalid' with 'net' to reply

      Comment

      Working...