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..
Code: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(); } }