在文件缓冲区上使用ifstream作为TCHAR * [英] Use ifstream on a filebuffer as TCHAR*

查看:106
本文介绍了在文件缓冲区上使用ifstream作为TCHAR *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Hans Dietrich关于如何将文本文件作为资源包含在exe文件XResFile中的精彩文章。我之前使用过ifstream的单独文件,



ifstream datfile(datf.txt)



我已经重载了>>运营商,我想继续使用。问题是该文章描述了返回TCHAR *的GetTextBuffer()。如何将此指针转换为ifstream对象?



谢谢。



Haakon。

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.

推荐答案

你不能。 ifstream 适用于文件和仅文件。如果你有一块内存,你想从中提取东西,那么使用 std :: strstream ,但需要注意的是它在C ++ '98和'03中被弃用了可能已在'11。
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.

中删除了

这篇关于在文件缓冲区上使用ifstream作为TCHAR *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆