#include<iostream>
#include<fstream>
#include<string>
using namespace std;
void test();
struct node
{
int num;
node *next;
};
void main()
{
int choice = 1;
while(choice)
{
test();
cout<<"input choice:"<<endl;
cin>>choice;
}
}
void test()
{
cout << "please input the directory of the file: " << endl;
string fn;
getline(cin,fn,'\n');
ifstream fop( fn.data(), ios::in|ios::binary);
char ch;
fop.seekg(0,ios::end);
int Pos_End = fop.tellg();
fop.seekg(0,ios::beg);
while( Pos_End != fop.tellg() )
{
fop.read((char* )&ch, sizeof( ch ) );
cout<<ch;
}
cout << endl;
fop.close();
}
==================================运行时input choice时两次输入1,调用test函数,报了如下错误:
Debug Assertion Failed!
Program:G:\我的文档\Debug\test.exe
File:fopen.c
Line:54
Expression: *file != _T('0’)
.....================================================================请教高手给予解答,感激涕零! ̄
#include<fstream>
#include<string>
using namespace std;
void test();
struct node
{
int num;
node *next;
};
void main()
{
int choice = 1;
while(choice)
{
test();
cout<<"input choice:"<<endl;
cin>>choice;
}
}
void test()
{
cout << "please input the directory of the file: " << endl;
string fn;
getline(cin,fn,'\n');
ifstream fop( fn.data(), ios::in|ios::binary);
char ch;
fop.seekg(0,ios::end);
int Pos_End = fop.tellg();
fop.seekg(0,ios::beg);
while( Pos_End != fop.tellg() )
{
fop.read((char* )&ch, sizeof( ch ) );
cout<<ch;
}
cout << endl;
fop.close();
}
==================================运行时input choice时两次输入1,调用test函数,报了如下错误:
Debug Assertion Failed!
Program:G:\我的文档\Debug\test.exe
File:fopen.c
Line:54
Expression: *file != _T('0’)
.....================================================================请教高手给予解答,感激涕零! ̄