Reputation: 2843
I have a .txt file saved in memory ( void *Buffer; UINT itsLen ). Is there any easy way to read this text file like std::wifstream read txt from a disk?
Upvotes: 0
Views: 84
Reputation: 119517
Yes; use a string stream.
#include <string>
#include <sstream>
...
wchar_t* p = static_cast<wchar_t*>(Buffer);
std::wistringstream s(std::wstring(p, p + itsLen/sizeof(wchar_t)));
The string stream s
can be used similarly to a std::wifstream
object.
Upvotes: 2