By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,323 Members | 1,761 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,323 IT Pros & Developers. It's quick & easy.

Visual C++ 6.0 Runtime Error

P: n/a
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;
}

Nov 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Nov 13 '06 #2

P: n/a
DragónChristiano <bj*******@gmail.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:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Nov 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.