Results 1 to 3 of 3

Thread: getch() wierdness..

  1. #1

    Thread Starter
    Junior Member xuralarux's Avatar
    Join Date
    Oct 2001
    Location
    I'm somewhere where I don't know where I am!
    Posts
    20

    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?

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Try using "<< endl;" instead of "<< "\n";" after each output line.

    Z.

  3. #3

    Thread Starter
    Junior Member xuralarux's Avatar
    Join Date
    Oct 2001
    Location
    I'm somewhere where I don't know where I am!
    Posts
    20
    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
  •  



Click Here to Expand Forum to Full Width