How would I get input like you would use INKEY$ in basic? I've been programming qbasic for a while now and now I want to try to transition to C++, but I can't find much about this.
I would search to see if this has been asked before but I just found this forum and I don't know where the search feature is (if there is one)
Which version are you using?
Version of what?
If you are asking what compiler I am using Dev-C++ 4.9.9.2 right now, although I plan to be possibly using a DOS version of Turbo C++ in the future
Edit: I was pretty far off. Read stylin's post below for the correct way.
You're going to want to use C++ headers (no .h) and C++ functions if you're learning C++:
Code:
# include <iostream>
int main()
{
char ch = std::cin.get();
// or ...
std::cin.get(ch);
...
return 0;
}
Start here:
http://msdn2.microsoft.com/en-us/library/22z6066f.aspx (the easiest way to learn C++ is by buying [a] book[s]. Good luck!
I tried that, and I noticed that it seems to just do a cin and then take the first character. I made this little program to print the characters on the screen
Code:
# include <iostream>
using namespace std;
char ch;
int main()
{
cin.get(ch);
cout << ch;
system("PAUSE");
return 0;
}
ps i think this program might be Dev-Cpp only, not sure.
Quote:I tried that, and I noticed that it seems to just do a cin and then take the first character.
That's because you're only storing one character. Store more characters and you'll be able to enter more data.
Either that or use std:
tring.
actually what I wanted to do was not have to press enter and return the key pressed
Do you want execution to wait until the user presses a key, or do you want to still be able to execute while checking for input?
either way, just want to be able to press a key and it does something