#include<iostream>
#include<fstream>
int main()
{
ifstream in("file.txt");
string s,str="";
//使用while循环判断是否读完
//判断文件是否为空时使用peek函数,若peek返回EOF则文件为空
while(getline(in,s)){
str+=s;
}
cout<<str<<endl;
return 0;
}
#include<iostream>
#include<fstream>
string s,str="";
//使用while循环判断是否读完
//判断文件是否为空时使用peek函数,若peek返回EOF则文件为空
while(getline(in,s))