ifstrean读取文件
#include<bits/stdc++.h>
using namespace std;
int main()
{
ifstream myfile("D:\\VScodeC++\\file\\hello.txt",ios::in);
string temp;
if (!myfile.is_open())
{
cout << "未成功打开文件" << endl;
}
string res;
while(getline(myfile,temp)){
res+=temp;
res+='\n';
}
cout<<res;
myfile.close();
system("pause");
return 0;
}
按原格式输出文件内容