Mail Archives: djgpp/1997/08/27/18:09:43
"Locke" (lockeg AT usa DOT net) writes:
> Hey everyone,
>
> i am feeling really stupid, but i need help. I have been working on this
> game and it's going verrry well, but i've hit a wall. I can't believe
> this, but i can't remember how to write an array of structures to a file!
>
> for instance... say i have a structure called S_MAP it goes as follows:
>
> typedef struct
> {
> char *name;
> int tiles[MAX_Y][MAX_X];
> } S_MAP;
>
> S_MAP Maps[MAX_MAPS];
>
>
> That's a very watered down version of the structure, but it gets the idea
> across...
> Anyway, i want to write the variable Maps to a file and then later read it
> back in. I can't believe that I can write low level graphics routines, a
> keyboard handler and all this really complicated stuff, but can't remember
> how to write to a file. Well, any help would be greatly appreceated...
fwrite(Maps,sizeof(S_MAP),MAX_MAPS,my_file_pointer_returned_by_fopen);
Two remarks: one: this is documented in the info files, info libc a
fwrite. Two, this is a general C question, and might be better placed in
comp.lang.c.
--
.*. Where feelings are concerned, answers are rarely simple [GeneDeWeese]
-() < When I go to the theater, I always go straight to the "bag and mix"
`*' bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh
- Raw text -