samedi 22 avril 2017

Writing char* into a basic_streambuf and assign it to a ifstream

I have a problem, mostly because I can't really understand how to handle the situation.

I have a char* buffer of X size, it's the content of an encrypted file who's got decrypted and will be then parsed by the ifstream handler class that i can't edit.

So my idea was to create an fstream object in which, with rdbuf() assign the buffer with sputn.

fstream _handle2; _handle2.rdbuf()->sputn(_buffer, _size); _handle2.flush();

But of course, it's not working and buffer does not get written into the fstream object, do you have any idea of how to make it so?

I tried different methods but I clearly can't figure out what to do.

Aucun commentaire:

Enregistrer un commentaire