Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to use Hans Dietrich's great article on how to include a text file as a resource in a exe file, XResFile. I have previously used a separate file with ifstream,

ifstream datfile("datf.txt")

where I have overloaded the >> operator, which I would like to keep using. The problem is that the article describes the GetTextBuffer() which returns a TCHAR*. How can I convert this pointer to a ifstream object?

Thank you.

Haakon.
Posted

1 solution

You can't. ifstream is for files and only files. If you have a block of memory that you want to extract stuff out of then use std::strstream, with the caveat that it was deprecated in C++'98 and '03 and might have been removed in '11.
 
Share this answer
 
Comments
Haakon S. 29-Jan-14 2:30am    
Thank you. I was suspection this. But I have found a way around it. I will make an extractor from the char array.
Haakon S. 29-Jan-14 4:17am    
Hey, std::strstream seems to work smoothlessly! Thanks a lot! Problem solved.
Aescleal 31-Jan-14 14:05pm    
Glad it helped!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900