#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
int main()
{
std::string NumberStr;
std::string DIDStr;
//文本应使用UTF-8类型编码
std::ifstream DIDList("did_table.txt", std::ios::in);
std::ofstream DIDList_Out("did_table_out.txt", std::ios::out);
if (!DIDList)
{
std::cout << "DIDList is NULL." << std::endl;
return 0;
}
getline(DIDList, NumberStr);
std::cout << "did number:" << NumberStr << std::endl;
int64_t Number = 0;
Number = atoi(NumberStr.c_str());
int64_t index_line = 0;
while (Number--)
{
if (!std::getline(DIDList, DIDStr))
{
DIDList.close();
return 0;
}
DIDStr = DIDStr.substr(0, 4);
std::string DIDStr_out;
DIDStr_out.push_back('"');
DIDStr_out = DIDStr_out + DIDStr.c_str();
DIDStr_out.push_back('"');
DIDList_Out << DIDStr_out;
if(index_line == 9)
{
DIDList_Out << std::endl;
index_line = 0;
}
else
{
DIDList_Out << " ";
index_line++;
}
}
DIDList.close();
DIDList_Out.close();
return 0;
}