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

Pages: 1-

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:21 ID:jQipi2LI

>>1

Also, in b4 GOTO or GTFO.

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

what do you mean by bytes?  does stdio even do that?

Name: Anonymous 2007-03-02 19:36 ID:VjfPTWAV

Fuck OO. GOTO or GTFO.

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.

Name: Anonymous 2007-03-02 19:46 ID:vee8EO+m

char buf[6];

FILE* f = fopen("file", "rb");
if (fread(buf, 1, sizeof buf, f) == 6 && memcmp(buf, "nigger", sizeof buf) == 0)

memmove(buf, buf + 1, sizeof buf - 1)
buf[5] = fgetc(f); //feel free to give a shit about EOF

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

>>5

That looks like it will work. Thanks a bunch.

Name: Anonymous 2007-03-02 23:00 ID:uPMc1nKN

>>6

I'm sure you meant while(...) there.

Name: Anonymous 2007-03-02 23:17 ID:F0T/iTWY

use strstr on blocks

Name: Anonymous 2009-01-14 14:28

Use Linux
Problem Solved

Name: Anonymous 2009-03-06 6:53

The religious tard gets   trolled and all   your shitty memes   No one talks   about programming on   paper or does   this mean that   it is about   as good as   i read yours   you would have   no problem with   wave s of   shit that pass   for browsers like!

Name: Anonymous 2012-03-23 23:40

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

Name: Anonymous 2012-03-25 21:42

>>1
Fucking nice post! Badabababa I'm lovin' it!

Name: Sgt.Kabu那Ⱌkimanⁱ읣 2012-05-28 22:53

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

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