-
Ahh the helpful FAQ
I am somewhat new to programming in C++, but not so much that I can't navigate it well. I go between 2 different versions of Visual C++ IDE, Visual C++ 6 and Visual C++.net 2002 std. I tried the suggestions in the FAQs "How do I Stop my Windows Console from disappearing everytime I run my program?" and " How do I get my program to wait for a keypress?" but it only works rarely. Is there an option hiding somewhere in the IDE to make it wait for a keypress? The cin.get() method does nothing for me. Can anyone help?
Meeloff
-
You could try using kbhit()...for example
Code:
int main ()
{
cout << "\nThis is a test to see kbhit()";
cout << "\n Prog. will not continue until you press enter";
while(!(kbhit()));
cout << "\n You hit enter";
return 0;
}
-
If you're getting input from the user in your program, try putting cin.get( ) twice. Or you could #include <cstdlib> and system ("pause");.
-
It only works rarely? You sure you start your apps with Ctrl+F5?
-
that could be it... if you're getting user input, some methods leave the '\n' in the stream, so the next cin.get() will just grab that as user input... if you have a cin or something just put cin.ignore(); after it. that should clear the input stream.
I prefer bloodshed's Dev-C++ compiler over any other windows compiler...