#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
char *stradd(char* str, char c) //str为原字符串,c为要追加的字符
{
int n = strlen(str);
str[n] = c; //追加字符
str[n+1] = 0; //添加结束符
return str;
}
int main()
{
ifstream infile("LOC.txt");
ofstream outfile("LOCResult.txt");
if(!infile)
{
cout<<"unable to open the source file."<<endl;
exit(1);
}
if(!outfile)
{
cout<<"unable to open the result file."<<endl;
exit(1);
}
string lines;
string buffer[4];
while(!infile.eof())
{
while(getline(infile,lines))
{
int i=0;
for(string::size_type index=0;index!=lines.size();index++)
{
if(lines[index]!='\t')
{
//buffer[0].append (lines,begin,index-begin);
buffer[i] += lines[index];
}
else if(lines[index]=='\t')
{
i++;
}
}
if(buffer[0]!=buffer[2] && buffer[1]=="/")
buffer[1]=buffer[2];
outfile<<buffer[0]<<"\t"<<buffer[1]<<"\t"<<buffer[2]<<"\t"<<buffer[3]<<endl;
buffer[0].clear();
buffer[1].clear();
buffer[2].clear();
buffer[3].clear();
}
//infile>>buffer[0]>>buffer[1]>>buffer[2]>>buffer[3];//遇到空格即存,没有考虑英文词语间必有的空格。会造成错误切分
}
infile.close();
outfile.close();
system("pause");
return 0;
}
1_C列与A列不同且B列为反斜杠,则将C列值拷贝到B列
最新推荐文章于 2023-10-08 20:00:46 发布