|
From: <aar...@ut...> - 2002-02-11 20:28:49
|
Hello... I have a question about closing a terminal window during a C++ program execution. I am using Dev C++ 4.01 as my compiler. At http://www.cprogramming.com/close.html, it says that inserting the line cin.get() before the return 0 line will keep the terminal window open until I press enter. This I find is true for the following program: #include <iostream.h> int main() { cout<<"The Compiler Works"; cin.get() return 0; } However for the following code, I type my number, press enter, and the window closes immediately. Why doesn't the compiler display "You entered: ", then my number, and then close the terminal window once I push enter (which would be the second time)?? Am I putting the cin.get() statement in the wrong spot?? Check out the code I'm using. #include <iostream.h> int main() { int thisisanumber; cout<<"Please enter a number:"; cin>>thisisanumber; cout<<"You entered: "<<thisisanumber; cin.get() return 0; } I'm stuck, and I'm trying to teach myself C++. Your help is greatly appreciated. Sincerly, Aaron |