ifstream iFile("****.txt");读取文件时发生错误。
****.txt 文件在Debug文件夹中,而且另外的定义也没有错,这句出错,没道理啊。VS2012。求指导?
贴一段在网上看到的例子,依然读取文件时发生错误(a.txt 文件已建立)。
调试时提示: {_Filebuffer={_Set_eback=0xcccccccc <读取字符串的字符时出错。> _Set_egptr=0xcccccccc <读取字符串的字符时出错。> _Pcvt=0x00000000 {...} ...} } std::basic_ofstream<char,std::char_traits<char> >
求指导。
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
int i;
string s;
ifstream ifile;
ifile.open("a.txt");
ofstream ofile1, ofile2;
ofile1.open("b.txt");
ofile2.open("c.txt");
while(ifile >> i >> s)
{
if(i > 100) ofile1 << i << "\t" << s << endl;
else ofile2 << i << "\t" << s << endl;
}
ifile.close();
ofile1.close();
ofile2.close();
}