Probs w/

Problems with pausing program execution.

I resolved on my own how to pause the program so I could see Hello World displayed.
cout << "Press any key followed by the ENTER key: ";
cin >> a; //the var a having heen declared before.

Then I was working on the while loop and an exercise was taking user input until the EOF key-sequence was input (on my system <ctrl-k> followed by ENTER).

The compiler ignored my technique to pause the program so I could see the display on screen
After some research I used the following statement:
cin.clesr();
And that resolved the issue.

Now I have a program that declares an array and initializes it 2 diff.ways.
I want to pause the proogram after the 1st way and again pause before the end.

It pauses after the 1st way but then runs thru w/o pause????
What should I do?
Last edited on
Could you post a small program that exhibits the problem? Remember to please use [code] tags.
try putting
 
system("PAUSE");

just before your return statement.
closed account (18hRX9L8)
Please, look at this sticky on how to hold the console: http://www.cplusplus.com/forum/beginner/1988/ . Also, please do not use system("anything"). Read here why not to: http://www.cplusplus.com/forum/articles/11153/ .

Ohh, I understand what you are trying to say now... Basically, whenever you cin >> anything, the newline character is still left in the stream. To get rid of this character, you need to enter: cin.ignore() after every cin >> statement... I believe that this solution can be dramatically improved (but I'm still a noob myself), so I suggest you read the sticky instead.
Last edited on
Topic archived. No new replies allowed.