Hello,
If I want to say compare a line at a given line number to another line at a different given line number how can I do this? I know I could iterate through the file and store the lines into a data structure and perform comparisons that way but the file is very large and was wondering how I could avoid that without taking up more memory? Or any other thoughts, thanks.
flipjoebanana
0
Junior Poster in Training
Recommended Answers
Jump to PostYou don't have to store all the lines, just the two lines that you want to compare. Sequentially read the file, counting lines as you go along then save only the two lines you want to compare.
All 3 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
flipjoebanana
0
Junior Poster in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.