-
Pausing
Hey everyone, I am new so be nice.
I was wondering how to pause the program to let the user read the output so far I have (note that this program is stupid and was just to figure out how to pause the program):
#include <iostream.h>
#include <stdlib.h>
int main()
{
int i;
int f;
cout<<"Hello world!\n";
cin>>i;
cout<<"Counting from 0 to "<<i<<endl;
cout<<"----------"<<endl;
for (f = 0; f <= i; f++) {
cout<<f<<endl;
system("PAUSE");
}
cout<<"----------"<<endl;
system("PAUSE");
return 0;
}
this program does not pause where I put 'system("PAUSE");' any solutions will be greatly appricated. Thanks in advance.
-
looks like there is nothing wrong with your code and it compiled perfectly in Dev C++ and worked exactly like its meant to (it pauses when its meat to). So I don't know what the problem is with your compiler or computer that isn't working...
-
oh I forgot to mention that I am using Microsoft Visual C++ 6.0 so that must be the problem. (I am most likely wrong here).
I have Dev C++ at home, but at school they only have Microsoft Visual C++.
-
One more thing...
When I compile the program and build the .exe when I run it it automatically closes, is there a way to stop it from doing this or at least get it to wait long enough to see the output?
-
-
Try using this command... you might need to include <conio.h> or <stdlib.h>
cout<<"\nPress any key to continue."<<endl;
getch();
if it wants you to input a character before it outputs the cout statement, you need to put
cin.ignore(1000,'\n');
before the cout.