In article <k4aa6c$5u3$>,
"Bill Cunningham" <> wrote:
> An tSin Gorm wrote:
> > In article <k4a9do$3t7$>,
> > "Bill Cunningham" <> wrote:
> >
> >> An tSin Gorm wrote:
> >>> In article <k4a768$t96$>,
> >>> "Bill Cunningham" <> wrote:
> >>>
> >>>> Can someone show me how to add 3 or so bytes to the end of a
> >>>> file? I have been studying and I'm thinking fseek() and fgetc()
> >>>> might be involved. I can't seem to find any examples online unless
> >>>> I'm overlooking something. Nothing in C that is.
> >>>
> >>> FILE *f = fopen(path, "r+");
> >>> fseek(f, 0, SEEK_END);
> >>> fputs("3 or so bytes", f);
> >>> fclose(f);
> >>
> >> Sorry I meant fputc but I guess fputs would work.
> >>
> >> Bill
> >
> > Or fprintf or fwrite.
>
> I'm kinda scratching my head here. Does you code append textual strings? I
> want to append '\0' to the end of the file and be able to reverse that
> process. Iprobably could go ahead and use a+ instead of r+ and skip the
> fseek.
I'm used to unix so text and binary files are the same; you can add "b" if
appropriate. Once the file is positionned, you can write the bytes with whatever
technique will write the bytes.
--
My name Indigo Montoya. \\ Annoying Usenet one post at a time.
You flamed my father. \' At least I can stay in character.
Prepare to be spanked. // When you look into the void,
Stop posting that! `/ the void looks into you, and fulfills you.
|