$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Pablo Aguilar (pablo.aguilar_at_[hidden])
Date: 2006-08-03 23:01:46
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