用流读取文件,并进行输出
#include <fstream>
#include <list>
std::string filename = "E:/worker_list/test.ini";
int main()
{
std::ifstream ifs;
if(ifs.is_open())
{
ifs.close();
ifs.clear();
}
ifs.open(filename.c_str());
std::string buf;
std::list<std::string> strlist;
while(getline(ifs,buf))
{
std::string line = buf;
if(!line.empty())
{
strlist.push_back(line);
}
}
ifs.close();
ifs.clear();
std::list<std::string>::iterator it;
for(it = strlist.begin();it != strlist.end();++it)
{
std::cout<<*it<<std::endl;
}
return 0;
}