Add cin.get() at the end of the main function, it waits for user input ( return key ) or you can use system("PAUSE") which I do not recommend because it uses more resources. Just giving you some options.
Hello, I'm fairly new to C++, and I am currently doing as one of the posts I found said to do. I got some books on c++ programming and am currently stuck having a problem keeping a program open after I have compiled and ran it. I am using Bloodshed DevC++ if that helps.
Add cin.get() at the end of the main function, it waits for user input ( return key ) or you can use system("PAUSE") which I do not recommend because it uses more resources. Just giving you some options.
I have used cin.ignore, cin.ignore(cin.rdbuf()->in_avail() + 1), return 0, and system("Pause") the only one that has worked is system("Pause"). I don't like how it adds the extra line, is there anything else that might work?
Extra line or use visual studio.
Also try cin.getch();
and cin.get(); cin.get(); twice in a row. I think sometimes there's problems with the buffer, and cin.get() will pull a character off of it before it clears or something. not sure
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
Arko_0 (08-26-2010)
Just use Visual C++ Express, it automatically adds "press any key to continue" right before the end of the program so it doesn't go away immediatly
cin.get(); cin.get(); worked.