Need assistance using files

My problem is as follows. I have a scanfile function that returns me and integer representing the location of the string if it finds it in the file. My next step is writing a function that will take that integer and return me that entire line in that file not just the string. Is there an algorithm thats fast that I can use. Any help is really appreciated. Thanks.

Comments

  • [b][red]This message was edited by Koppis at 2005-12-16 0:49:31[/red][/b][hr]
    : My problem is as follows. I have a scanfile function that returns me an integer representing the location of the string if it finds it in the file. My next step is writing a function that will take that integer and return me that entire line in that file not just the string. Is there an algorithm thats fast that I can use. Any help is really appreciated. Thanks.
    :

    Is filestream too slow for you? I think this would be easy to do using loop that will start from then integer value and loop until end of the file OR end of the line. You have to also read backwards to the end of the previous line OR beginning of the file.

    EDIT: Use some kind of buffer if you want to make it faster. Just read 1000 bytes backwards and forwards and start testing, won't be so slow as you could believe it is. Remember to test if that many bytes exist before reading, or you might just write some bug in your program.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion