65,212
社区成员
发帖
与我相关
我的任务
分享#include <iostream>
#include <fstream>
using namespace std;
typedef std::string String;
void loadDirect(const String& filename)
{
std::ifstream fp;
fp.open(filename.c_str(), std::ios::in | std::ios::binary);
if(fp.bad()) //误你妹,没有!
{
cerr<<"打开失败"<<endl; //cerr打印错误,否则出不来东西.
}
}
int main()
{
loadDirect("d:\\abc.txt");
return 0;
}
#include <iostream>
#include <istream>
#include <fstream>
using namespace std;
typedef std::string String;
void loadDirect(const String& filename)
{
std::ifstream fp;
fp.open(filename.c_str(), std::ios::in | std::ios::binary);
cout<<fp.rdbuf();
fp.clear();
if(!fp.bad())
{
cout<<"打开 失败。";
}
}
int main()
{
cout<<"Hello\n";
loadDirect("abc.txt");
return 0;
}