C++ 结合 Boost:40行代码读写和处理 txt 文件
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <boost/tokenizer.hpp>
using namespace std;
using namespace boost;
int main ()
{
string stringLine;
ifstream infile;
vector<string> tempLine;
vector<string> rootName;
string tempName;
ofstream fout( "rootFilterData.txt", ios::app);
infile.open ("All Simple_Test.txt");
while( !infile.eof() ) // To get you all the lines.
{
getline(infile,stringLine); // Saves the line in stringLine.
char_separator<char> sep(" ");
tokenizer<char_separator<char>> tok(stringLine, sep);
for(tokenizer<char_separator<char>>::iterator beg=tok.begin(); beg!=tok.end(); ++beg)
{
tempLine.push_back( *beg );
}
if ( tempLine[0][