Click to See Complete Forum and Search --> : newbe/cs student needs help


xerocontrol
February 27th, 2002, 06:11 PM
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]

NMTop40
February 27th, 2002, 06:30 PM
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

Radius
February 28th, 2002, 06:29 PM
What, you're doing his homework for him? :P