🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #4592

I/O of complex data structures in C

#4592
From: Jason Freund
Date: Fri, 03 Aug 1990 00:02
35 lines
2194 bytes

-- somewhat hypothetical situation representing a real problem --

	Ok.  Suppose I am writing a game in ansi C that saves a bunch of 
different maze levels as separate files.  The player walks around, changes
some things, and then leaves.  When the game starts, I want to load level 1.
Everytime he changes levels, I load up the new level and save the old one.

	Basically, a maze is a complex data structure (a 2D array of and array
of pointers to blah, blah... (it's deep)).  So that means I want to use fread()
and fwrite() (right?)  My programming book says *very* little on those
commands, but what they do say leads me to believe that those are the commands
I want.  

	When you save data in a database, does the program just go:
"fwrite(pointer, sizeof, *pointer, items, stream)" which somehow magically
saves every piece of data (specified in the arguments) in such a way that it
will be able to read in every piece of data back into their correct cells in
the data structure?  That is what I want to do -- and I want to know if fread
and fwrite can do it.

	Could someone explain in some detail what the arguments mean? Or point
me to a source that could?

Thanks,

Jason Freund, Sun Microsystems,  jasonf@cetemp.Corp.sun.com  <== summer address
Deprtmnt of Computer Science, Univ California, Davis. freund@sakura.ucdavis.edu
Quantum Link: JasonF5,  Compu$erve: 72007,244, 690 Erie Dr, Sunnyvale, CA 94087
-------------------------------------------------------------------------------
STOLEN QUOTES -- Please give the authors credit if you know who they are!    
"To understand recursion, you need to understand recursion."
"Wow!  Virtual memory!  Now I'm gonna build me a REALLY big ram disk!"
"My other computer is a SUN3/50."  "E. Pluribus UNIX"   -- authors unkown 
Technical Details
Message-ID: <140087@sun.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!ames!sun-barr!newstop!sun!jasonf

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!ames!sun-barr!newstop!sun!jasonf
From: jasonf@cetemp.Eng.Sun.COM (Jason Freund)
Newsgroups: comp.sys.amiga.tech,comp.lang.c
Subject: I/O of complex data structures in C
Message-ID: <140087@sun.Eng.Sun.COM>
Date: 3 Aug 90 00:02:52 GMT
Sender: news@sun.Eng.Sun.COM
Followup-To: s
Lines: 35