Visual C++ 6.0 Runtime Error

  • Thread starter =?iso-8859-1?q?Drag=F3nChristiano?=
  • Start date
?

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

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

Marcus Kwok

DragónChristiano said:
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
 
V

Victor Bazarov

DragónChristiano said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top