hey, im writing a prog in C++ for DOS console. i want to know how to make the program ask for keyboard input, return it, then save it to a string for later use. teacher never went over it and cant find examples.
thank you very much
xerocontrol [gzc]
Printable View
hey, im writing a prog in C++ for DOS console. i want to know how to make the program ask for keyboard input, return it, then save it to a string for later use. teacher never went over it and cant find examples.
thank you very much
xerocontrol [gzc]
to ask for a string on the console, use
std:string sin;
std::cin >> sin;
or
std::getline( std::cin, sin );
either way will get you a string. The difference is, the first one will only give you the word up to the first whitespace character while the second will give you a whole line.
Both will be stored in the variable sin
The best things come to those who rate
What, you're doing his homework for him? :P