-
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.
-
Try using "<< endl;" instead of "<< "\n";" after each output line.
Z.
-
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.