Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How do I scan a txt file to find lines that have duplicates 35 characters long and delete that whole line?

What I have tried:

How do I can a txt file to find lines that have duplicates 35 characters long and delete that whole line?
Posted
Updated 3-Aug-18 15:38pm
Comments
[no name] 3-Aug-18 18:06pm    
Duplicates from beginning, in between or what else. Can you explain something more precise how you define "that have duplicates 35 characters long " ?
[no name] 3-Aug-18 19:52pm    
from the beginning.

1 solution

The basic algorithm is :

open the input file for read access
open an output file for write access
read line of text from input file
evaluate for duplication
if not a duplicate then write that line to the output file
continue reading and writing until end of file found (the read fails)
close the files

at this point you can copy the output file to the input if you want to replace it or if you don't want to then you are done.

I would likely use fopen, fgets, and fputs for the file access but you could also use streams if that is what you are most comfortable with.

As for the code, you have to write that yourself because it's not my homework.
 
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