Adding details to a file

Hi all, I need some help with c++ .txt files, I just need a general description of how should I go about doing what I need to do...

Sample txt file:
11/11/2008
<record1>
<record2>
<record3>

After processing it, I need to add details at the back of the records like so:
Sample txt file:
11/11/2008
<record1><extra details>
<record2><extra details>
<record3><extra details>

How do I go about doing this?
You can try the code as this:

/////////////////==WinXP sp2 + VC8.0 pass==/////////////////////////////////////////
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/********************************************************************
	created:	2008/07/12
	created:	12:7:2008   0:45
	filename: 	e:\Coding\CPP_AddExtra\CPP_AddExtra\CPP_AddExtra.cpp
	file path:	e:\Coding\CPP_AddExtra\CPP_AddExtra
	file base:	CPP_AddExtra
	file ext:	cpp
	author:		hecan
	
	purpose:	add extra details
	=============test ================
	 input data "input.txt":
	11/11/2008
	<record1>
	<record2>
	<record3>

	 output data "output.txt":
	 11/11/2008
	 <record1><extra details >
	 <record2><extra details >
	 <record3><extra details >

*********************************************************************/

#include <fstream>
#include <string>
#include <algorithm>
#include <iostream>
//#include <fstream>

using namespace std;

int main()
{
	ifstream isData("input.txt", ios::in);
	if (!isData)
	{
		cerr << "Can't open file!" <<endl;
	}
	ofstream osData("output.txt", ios::out);
	string sLine;
	while (getline(isData, sLine))
	{
		if (sLine.find("<")  != string::npos)
		{
			sLine += "<extra details >";
			osData << sLine <<endl;			
		}
		else
		{
			osData << sLine <<endl;
			continue;
		}
	}
	isData.close();
	osData.close();
}
Topic archived. No new replies allowed.