DGortze380
September 4th, 2008, 09:12 PM
Hey all,
I blew through writing this program for class right up until this last problem. I can't get the damn thing to wait for the user to press the enter key.
example (not the actual program):
#include <iostream>
using namespace std;
int main()
{
int x=0;
while (true)
{
cout << x << endl
x++;
switch (x) //syntax for this switch example is probably off, didn't look it up.
case 1:
//some function call
break;
case 2:
//some function call
break;
default:
break;
cout << "press enter to continue";
// WTF will work here? I tried the following:
// cin.ignore();
// cin.get();
// cin >> someVariable
// getch(); //this one didn't work because I don't have the library and don't want to install it. Need an ANSI C solution
// all of these do nothing, it just keeps looping.
// cin >> someVariable works, but you have to type something and press enter. I just want to wait for 1 key stroke.
}
return 0;
}
help.
I blew through writing this program for class right up until this last problem. I can't get the damn thing to wait for the user to press the enter key.
example (not the actual program):
#include <iostream>
using namespace std;
int main()
{
int x=0;
while (true)
{
cout << x << endl
x++;
switch (x) //syntax for this switch example is probably off, didn't look it up.
case 1:
//some function call
break;
case 2:
//some function call
break;
default:
break;
cout << "press enter to continue";
// WTF will work here? I tried the following:
// cin.ignore();
// cin.get();
// cin >> someVariable
// getch(); //this one didn't work because I don't have the library and don't want to install it. Need an ANSI C solution
// all of these do nothing, it just keeps looping.
// cin >> someVariable works, but you have to type something and press enter. I just want to wait for 1 key stroke.
}
return 0;
}
help.