文件行读入

#include <isotream>

 #include <fstream>

 #include <string>

 using namespace std;

 int readFile(char fileName[]) //fileName是需要处理的文件名

{ ifstream in(fileName);

if (!in) { cerr << "Cannot open the file:" << fileName << endl;

exit(EXIT_FAILURE); }

string str = "";

while (getline(in,str))

 { //调用str.substr()截取三个字符进行处理 }

in.close(); }

 

你可能感兴趣的:(文件)