Editing txt file

hi eveyone
i need to edit person name or Appointmendescription but not date or time in my program. i can write all the records to the file and can read from the file.
and need to edit the file now. can anyone help????
thanks..
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
60
61
62
63
64
65
66
67
68
void writeAppointmenRecords( )
{
	int index;
		//create and open an output text file

       ofstream outfile("C:\\AppointmenRecords.txt",ios::out | ios::app);
	   // Check if file is opened
            if(!outfile)          //return true if file is not opened
	  {  cout<<"\nFailed to open file!!!!\n";
         cout<<"\nPress any key to proceed ";
		 cin.get();        //read a character         
	  }
		
	for (index=0; index<currentSize; index++)
	{
        outfile<<AppointmenList[index].name<<endl;
		outfile<<AppointmenList[index].description<<endl;
		outfile<<AppointmenList[index].time<<endl;
		outfile<<AppointmenList[index].appdate.day<<" ";
		outfile<<AppointmenList[index].appdate.mounth<<" ";
		outfile<<AppointmenList[index].appdate.year<<endl;
	}  
     //write records to the file.
		outfile.close( );    // close file
		cout<<"\n\nRecord(s) has been written to the file successfully!!!"<<endl;
		cin.get();
}

void readAppointmenRecords( )
{  
	//create a stream and open the file 'AppointmenRecords.txt' for input

	 ifstream infile("C:\\AppointmenRecords.txt", ios::in);
		// check if file is opened
		  if(!infile)          //return true if file is not opened
	  {  cout<<"\nFailed to open file!!!!\n";
	                            //indicate program failed
	  cin.get();
	  }
		  while (!infile.eof())    //eof( ) End Of File function. Returns false if end file reached
       {
		infile>>AppointmenList[currentSize].name;
		infile>>AppointmenList[currentSize].description;
		infile>>AppointmenList[currentSize].time;
		infile>>AppointmenList[currentSize].appdate.day;
		infile>>AppointmenList[currentSize].appdate.mounth;
		infile>>AppointmenList[currentSize].appdate.year;
		currentSize+=1;
        }
    infile.close( ); // close file
	currentSize = currentSize -1;
	cout<<"\n\nRecords has been read from the file successfully!!!"<<endl;
	cin.get();
    
}
void editAppointmenRecords( )
{
	int editname;
	system("cls");  //clear screen
	cout<<"\nEnter person Name you want to Edit: ";
	cin>>editname;
	ifstream edfile("C:\\AppointmenRecords.txt");
	if(!edfile)          //return true if file is not opened
	  {  cout<<"\nFailed to open file!!!!\n";       //indicate program failed
		 cin.get();                       
	  }
}
Topic archived. No new replies allowed.