首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

关于头文件的使用有关问题

2013-02-15 
关于头文件的使用问题我把#includeiostream.h#includefstream.h改成#includeiostream#includefstre

关于头文件的使用问题
我把
#include<iostream.h>
#include<fstream.h>
改成
#include<iostream>
#include<fstream>
using namespace std;
后程序就出错了
程序是读一个文件
关于头文件的使用有关问题
然后修改前运行是
关于头文件的使用有关问题
修改后运行是
关于头文件的使用有关问题
出现乱码了
下面是我的代码,应该没有问题
#include "stdafx.h"
#include<iostream.h>
#include<fstream.h>
int main(int argc, char* argv[])
{
int i=0,len=0;
ifstream file("letter.txt");
if(!file)
{
cout<<"未能打开test.txt文件"<<endl;
return 0;
}
char str[100];
while(file>>str[i])len++;//求出文件长度
cout<<len<<endl;
file.close();
file.open("letter.txt",ios::in);
while(i<len)
{
file.seekg(i);
file.get(str[i]);
cout<<str[i];
i++;
}
file.close();
return 0;
}
还有个问题是如果不重新打开文件也就是去掉
file.close();
file.open("letter.txt",ios::in);
后也是出现乱码,求各位指点一下原因
[解决办法]
为什么不直接打开include目录下(VC6是C:\Program Files\Microsoft Visual Studio\VC98\Include\)
iostream.h
fstream.h
iostream
fstream
这四个文本文件一看究竟呢?
[解决办法]
如果LZ是用的VC6,iostream和iostream.h是两个不同的库。

热点排行