C 中,我用ifstream打开txt文件,文件里本储存了许多字符,但在DOS界面里却并未显示,为什么?

[复制链接]
查看11 | 回复2 | 2011-3-10 07:27:15 | 显示全部楼层 |阅读模式
#include \"stdafx.h\"
#includeiostream
#includefstream
#includestring
#includemath.h
using namespace std;

int main(arraySystem::String ^ ^args)
{
ifstream fin(\"wordsconsolidation.txt\");
char ch;
while(fin.get(ch))
{
coutch;
}
fin.close();
int temp;
cintemp;

return 0;
}
顺便问一下,对于需要导入C的txt文件的储存的位置有特殊要求吗?
回复

使用道具 举报

千问 | 2011-3-10 07:27:15 | 显示全部楼层
<pre id=\"best-answer-content\" class=\"reply-text mb10\">这句话有问题fin.get(ch)
这样试试finch;
还有你的txt文件要放在你的工程目录下
当然是有要求的 或者你在 ifstream fin(\"wordsconsolidation.txt\");里面wordsconsolidation.txt变成你文件存储的绝对路径

















<h4 class=\"ask\">追问





<pre class=\"replyask-text\" id=\"content-1302503\">那么该txt文件应保存在哪里?
回复

使用道具 举报

千问 | 2011-3-10 07:27:15 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-1302626\">随便保存在哪里都行 只有在你的 ifstream fin(\"wordsconsolidation.txt\");里面wordsconsolidation.txt变成你文件存储的绝对路径 就可以了比如C:\\\\wordsconsolidation.txt
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行