1_C列与A列不同且B列为反斜杠,则将C列值拷贝到B列

#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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值