Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C File IO

Name: Anonymous 2007-03-02 19:21 ID:jQipi2LI

Guys, I fail hard at file I/O in C. What I'm trying to do is this:

Open the file
Read the first six bytes of the file
Compare it to blah, where blah is a character array
If it equals blah, do this stuff, otherwise
Shift forward one byte in the file and repeat.

The shifting part is kind of like a queue: basically, you go from FILE[0-5] to FILE[1-6] then FILE[2-7] and so on and so forth until EOF.

Can someone help me? In b4 forced indentation, Ruby on Rails, Opera, do your own homework, etc.

Name: Anonymous 2007-03-02 19:43 ID:Qnb1ykBf

I guess you just mean characters?

Basically just acquaint yourself with fseek and fgets:
fseek (the_file_stream, -4, SEEK_CUR) would set you to the point for the next read after an fgets(string, 6, the_file_stream).  Throw those together in a while construction and you should be set.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List