c++根据文件名读取.txt文件

新手代码如下:

#include<iostream>

#include<fstream>
#include<string>
using namespace std;
int main(){
string filename = "";  
cin>>filename;   //输入文件名
ifstream file(filename.c_str()); 
char buffer[16384];
while(!file.eof()){
file.getline(buffer,16383);
cout<<buffer<<endl;
}
cin.get();
cin.get();
return 0;
}

猜你喜欢

转载自blog.csdn.net/Iris54Iris/article/details/80136454