PW> JL> for some reason I can't seem to input a string with spaces in it.
PW> JL> am I missing something? like:
PW> JL> char testvar[100]; cin >> testvar;
PW> JL> how come I only get the first word?
PW>
PW> It stops reading when it hits whitespace, IIRC.
JL> thanks, but is there any way to input a string with spaces in it?
JL> (all into the same variable)
How do you know when the variable is supposed to stop getting characters?
If you have a sentinel character (a terminating character - such as the space
above), you can use getline (you can optionally specify the sentinel). I
believe it is cin.getline(testvar, sizeof(testvar), sentinel) - if you don't
specify the sentinel, a '\n' is used (i.e., the enter key).
Good luck!
--- Maximus/2 3.01
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|