View Single Post
Old Apr 18th, 2007, 4:29 AM   #1
357mag
Hobbyist Programmer
 
Join Date: Mar 2005
Posts: 148
Rep Power: 4 357mag is on a distinguished road
Why do I have to enter two cin.get()?

I just installed Visual Studio 2005, and tried a simple program using C++. A console program. After my code was entered, I ran the program and it worked but the console window closed really fast. So I looked in one of my C++ books and the author said try writing cin.get() just before the return 0 statement. I tried that but it didn't work. A few sentences later he said in some environments you may have to enter cin.get() twice. I tried that and it worked.

Anyone know why that is? And are there any alternatives to entering cin.get() that would keep the console window open?
357mag is offline   Reply With Quote