4 Aug
2006
4 Aug
'06
3:01 a.m.
Tommy Li wrote:
Great. Thanks a ton. The problem I was having was that I was using getline to read from stdin, which stripped the newlines (duh). Changing it to while(!cin.eof()) input.append(1, cin.get()); fixed it.
By the way, do you have a better way of reading the entire stream, including newlines, into a string?
How's this work for you: void f() { // ... int const buff_size = 4096; char buff[buff_size]; string str; while( !cin.eof() ) { cin.read(buff, buff_size); str.append(buff, cin.gcount()); } // ... } HTH, Pablo