[Help]Keeping program open

Posts 1–9 of 9 · Page 1 of 1
[Help]Keeping program open
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?
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
Extra line or use visual studio.
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
Quote Originally Posted by Ionizer View Post
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
Does it? mine doesnt
Quote Originally Posted by Hell_Demon View Post
Does it? mine doesnt
Does for me /
Thanks
cin.get(); cin.get(); worked.
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us