|
From: Bob C. <rc...@ps...> - 2002-02-11 21:39:43
|
You forgot the semi-colon at the end of cin.get() it should be cin.get(); ----- Original Message ----- From: <aar...@ut...> To: <dev...@li...> Sent: Monday, February 11, 2002 3:28 PM Subject: [Dev-C++] Dev C++ Question > 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 > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |