Click here to Skip to main content
16,007,504 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
please help me to delete the record from the .txt files by c++ coding in any project of c++
Posted

1 solution

1) Open existing file using CStdioFile for reading
2) Open a new file with temporary name for writing
3) Read first file and copy line by line to second file, skipping lines you want to delete
4) Close both files when reached the end of first file
5) Delete the first file
6) Rename 2d file into the old file's name.

Liberally sprinkle some error handling (like checking that second file is ok before deleting the first one)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900