in reply to Re: reading a random line from a file
in thread reading a random line from a file
Using seek for this is probably not a very good idea. Consider a file with these two lines:
Most random seeks will end up in the second line. If you move backwards, you'll almost always pick the long line. If you move forwards, you'll almost always pick 'z'. One way or the other, your distribution isn't random at all but determined by line length.a bcdefghijklmnopqrstuvwxy z
BrowserUk had the good sense to point out that the lines would have to be padded out to equal length to use this method.
-sauoq "My two cents aren't worth a dime.";
|
|---|