|
-
Jan 26th, 2003, 11:36 PM
#1
Thread Starter
Junior Member
getch() wierdness..
On Borland 5.5.1, I'm using getch() to pause after the lines. However, it only pauses after certain lines.
Code:
#include <conio>
#include <iomanip>
using namespace std;
int main() {
int a, b, bigval;
a = 8;
b = 5;
bigval = 7000;
cout << "Hello There." << endl <<
"After certain lines, the program will pause so the output can be read.\n" <<
"Just press any key to continue.. :)\n";
getch();
cout << "Here is " << b << "\n";
getch();
cout << "The manipulator endl writes a new line to the screen.\n";
getch();
cout << "Here is a big number...\t" << bigval << "\n";
getch();
cout << "Here is the sum of " << a << " and " << b << "... " << a + b << "\n";
getch();
cout << "Here is a fraction... " << b << "/" << a << "\n";
getch();
cout << "My name is ****, and I'm a C++ great programmer.\n";
getch();
return 0;
}
It's an old assignment, hence the goofy little "I'm a great programmer, and I believe in my silly self-esteem" bit.
I'd like to know if anyone else gets the same bug, what exactly is happening, and how to get around/fix it in the future.
Before you say anything about this post...you're welcome.
"I love animals... I eat them and wear their skin."
"Why do those who know the least, know it the loudest?"
"You live and learn. Or you don't live long."
Which Colossal Death Robot Are You?
-
Jan 27th, 2003, 01:59 PM
#2
Frenzied Member
Try using "<< endl;" instead of "<< "\n";" after each output line.
Z.
-
Jan 27th, 2003, 06:39 PM
#3
Thread Starter
Junior Member
Actually, endl is what I was using before, and it started skipping certain getch's from the get-go. Is there something about the Borland compiler, or mebbe certain config options I've chosen that cause this? I'd appreciate any info, screwy and unjustified behavior like this really irks me.
PS - My compiler is the command line one, I'm using Crimson Editor as a front-end for it.
Before you say anything about this post...you're welcome.
"I love animals... I eat them and wear their skin."
"Why do those who know the least, know it the loudest?"
"You live and learn. Or you don't live long."
Which Colossal Death Robot Are You?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|