|
From: <wa...@wa...> - 2004-02-13 17:45:02
|
On 13 Feb 2004 at 18:10, Per Westermark wrote: > Oooh. Lots of code, and memory intensive if the file is really big. Well, everything's a tradeoff. If you get intensive with the memory, you get the benefit of the code being a little faster. With the algorithm I wrote up, you only have to read the file once and then you can access the line you want immediately. With your first algorithm, you've got to read the same information over and over. And I don't think my version would be bigger code-wise. Your second algorithm is making the assumption that the random number is generated by the program and can refer to a random place in the file as opposed to a random line in the file. I was making the assumption that the random number would be supplied by the user. After re-reading the OP's question, I think you're right. > No need to fight with Windows API unless speed is > absolutely imperative, i.e. normal c/c++ file operations are > quire ok to use. I didn't know that Windows had separate file operations per se. I was assuming he'd use the regular file streams. But I'm not sure if the point of the assignment is to teach them how to read text files or use Windows. If you'll notice, the OP said specifically that the program was to use the Windows API and that refreshes should be done by hitting a button. That looks like the point is more how to write Windows code than to read text files. Watson (the pencil neck) Davis |