// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include<sstream>
#include<string>
#include <fstream>
#include<algorithm>
#include <vector>
using namespace std;
int main()
{
ifstream ifs;
ifs.open("./text.txt", ios::in);
if (!ifs.is_open())
{
cout << "open error" << endl;
return -1;
}
string temp;
string str;
vector<vector<string>> i_content;
while (getline(ifs,temp))
{
vector<string> i_temp;
istringstream ifst(temp);
ifst >> str >> str >> str >> str>>str>>str;//用第6列来和"nn"来比较。
if (str == "nn")
{
auto it = temp.begin();
while (it != temp.end())//因为istringstream会跳过"",所以添加该步骤。
{
if (*it == *(++it) == '/t')
{
temp.insert(it, 1, 'N');//用N来表示这个是null的""
}
}
istringstream istr1(temp);
while (istr1 >> str)//把该行全部一 一添加进去。
{
i_temp.push_back(str);
}
i_content.push_back(i_temp);
}
}
return 0;
}
结果如图
文档如图