65,210
社区成员
发帖
与我相关
我的任务
分享
#pragma once
vector<string> loadFile(const string &filePath);
#include "test.h"
//...
vector<string> loadFile(const string &filePath)
{
string buf;
vector<string> svec;
ifstream in(filePath);
while (getline(in, buf)) {
svec.push_back(buf);
}
return svec;
}
#include"test.h"
//...
int main()
{
vector<string> svec = loadFile("D:/cpptest/1.txt");
for (auto &str : svec) {
cout << str << endl;
}
system("pause");
}
