[ back to toc ]

I think it is fopen

Date: 2002/02/15 09:20

Q:
I am a novice C programmer and I have been making a command line e-mail
address orginaizing utility for Mac OS X(10.1/darwin1.4.1), I do need some
help fixing my search utlitiy and maybe some other bugs too but I have no
idea about how to save my struct onto a file so that It may be used later,
right now all that I can do is enter and list and delte and search(While
for some reason searching is not working right now) and then when I exit
the program natrually all the memory is gone, and this is painful and
pointless, so I have started putting in functions for saving and opening
the file, my file is at www.geocities.com/eddiepbti/database6.c and my
question is if you could tell what I would use to do it and then help me
implament it. Just email back here, and maybe you also want to email me
again for a more recent version, because every day I work on it and I
uploaded that version last night and even that one might have a little
something different from mine, but newer versions that I make do not
tamper with the file opening and closing. So please don't change how the
program is just tell me how I would open and save a file, I have not tried
anything since I have no clue where to start.
Thank you,
*NAME-DELETED* *NAME-DELETED*
A:
Hello *NAME-DELETED*!

The standard C library contains the function fopen that opens a file and
returns a handle to the opened file. This handle is to be used during file
operations until finally you close the file calling fclose.

I am not listing here all the commande description, but direct you to see
the man pages, or some other documentation on fread, fwrite, read, write,
open, close, fseek, seek, tell, ftell.

The main issue you have to face is how you convert your data structure
into byte stream and from byte stream to internal memory data structure.
That needs programming and that is really you have to solve it.

Regards,
Peter

[ back to toc ]