in reply to Searching text files

Basic data structures and algorithms question: use a binary search.

Assumption: Files are sorted lines of 10 numbers followed by a newline.

Your record size is 10+length('\n') (this is a text file by definition)

See seek(), wikipedia, google, and a book on the topic. Most introductary CS texts will also address this topic.

Your search time should be O(log2(n)), which is execllent - for 3 million records you are looking at a maximum of 22 comparisons.

I hate to say this, but most of the answers on this thread are way too complex.

--MidLifeXis