小编E.P*_*gar的帖子

C++:读取没有扩展名的文件

我有一些文件类型为"文件"我的意思是代替"资源\ sample.txt",他们的名字是"资源\样本"现在我想用c ++读取它们并将它们存储在一个字符串中.这是我的代码:

std::stringstream textBuffer;
std::fstream fileHandle;
std::string content
fileHandle.open("Resource\sample", std::ios::in);
textBuffer << fileHandle.rdbuf();
content = textBuffer.str();
fileHandle.close();
Run Code Online (Sandbox Code Playgroud)

但是当我编译它时,"content"变量的值等于"".帮助我.提前致谢.请注意,唯一的问题是文件没有任何扩展名,例如.txt或.dat或.bin.

c++ fstream file istream ostream

0
推荐指数
1
解决办法
646
查看次数

标签 统计

c++ ×1

file ×1

fstream ×1

istream ×1

ostream ×1