How can I have my program find a string in a file. I am using C.

I want my program to look for a string in a binary file. After it finds the string I want it to read 128 bytes after the string. When it prints that information to the screen, I want it to continue looking. If it finds another, it will print the 128 bytes after it to the screen. I want it to do that until it reaches the end of the file.

I am also looking for a way to have it read something between 2 different strings. For example, if I have the string "STARTDATA-" and "-ENDDATA" I want it to read everything in between those.

Here is what the file I am trying to read looks like:
[code]
HIVE-STARTCELL-example1.jpg-STARTDATA-(the binary for example1.jpg)-ENDDATA-ENDCELL-STARTCELL-example2.jpg-STARTDATA...(and so on)
[/code]
I want it to read the file names(example1.jpg, example2.jpg, etc.). Later I want it to, when I choose a file, to read the binary for that file and then copy it to a buffer and then write the stuff in the buffer to a file, and continue until all the data between the "STARTDATA-" and "-ENDDATA" tags have been copied and written to the file.

How would I accomplish reading the stuff after and between the strings?
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