every time i try to run a program they get to the least output and just cut off before i can see anything.i have tried to use system("pause"); and cin.get(); return 1;but neither work.all the tutorials say to use system("pause") but it doesnt work so somebody said to use cin.get(); return 1; so i did and it only works some of the time but cuts off.what can i do to make system ("pause"); work?
#include %26lt;iostream%26gt;
using namespace std;
int main(){
int myArray[3];
cout %26lt;%26lt; "Enter a number: ";
cin %26gt;%26gt; myArray[0];
cout %26lt;%26lt; "Enter a second number: ";
cin %26gt;%26gt; myArray[1];
myArray[2] = myArray[0]+myArray[1];
cout %26lt;%26lt; "The sum is: " %26lt;%26lt; myArray[2];
system ("pause");
}
other 1
#include %26lt;iostream%26gt;
using namespace std;
int main(){
int myArray[3];
cout %26lt;%26lt; "Enter a number: ";
cin %26gt;%26gt; myArray[0];
cout %26lt;%26lt; "Enter a second number: ";
cin %26gt;%26gt; myArray[1];
myArray[2] = myArray[0]+myArray[1];
cout %26lt;%26lt; "The sum is: " %26lt;%26lt; myArray[2];
cin.get();
return 1;
How come all of my c++ programs cut off to soon?
What you can do is open a DOS shell (or whatever Windows uses) and run the program directly from the command line. You will have to cd into the directory where the programs reside.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment