Original Post
I don't usually have a problem with C++ streams, but it's been a while since I did much in detail with them, so I am unsure what the problem is here. Here's my stripped down code:
#include <sstream>
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
stringstream destination_buffer(ios::binary);
ifstream input_file("c:/somefile.raw", ios::binary);
destination_buffer << input_file.rdbuf();
string word;
while (destination_buffer >> word)
cout << word;
cout << "All done." << endl;
return 1;
}
The idea being to open a file, read it all into a stringstream, and then use cout to write it. If I don't set both streams to binary, I won't be able to read the whole file (a graphic). But setting them to binary, it seems that there is never anything in the stringstream. I'm getting the impression stringstreams aren't much good at dealing with binary data, right? All I am trying to do is pretty much get that whole file buffered into memory. So, what am I doing wrong, and what should I be doing instead?
Edited by - Kylotan on 4/21/00 8:36:55 PM