i have a question is there a way to make cin to read in all characters... i just use it straight out (ie cin >> ch; )
it never grabs the \t \n and other such characters....
i want to read in a char at a time from a file, and if
ch == '\t' to print 4 spaces instead of putting a tab.
any help would be appreciated.
Use the get function to read single characters:
file.get ( ch );
get doesn't have a delimiting value, so it will happily read whitespace.
if you wish to have a delimiting value, or a limiting size, then getline() can be very useful, too. Beware, however, that there are some special issues when preceding a call to getline by any of the other cin methods.
>that there are some special issues
Those issues being the same behavior as scanf, cin will leave a newline in the input stream and getline will read the newline and end. The fix for this is either
while ( getchar() != '\n' );