Page 1 of 1

Open files.......but how?

PostPosted: Tue Jun 16, 2009 7:36 am
by savvy
can anyone tell me how to make it so that when you click on something, it opens a file?

if it is the fopen, then which options do i choose!

Re: Open files.......but how?

PostPosted: Tue Jun 16, 2009 7:44 pm
by skydereign
It depends on what file you want to open... kind of. For the most part I would say fopen.

fopen will open a named file and return a stream. If there is no named file, or another error occurs, it returns NULL. To be able to do things within a file, you should create a FILE*.

Code: Select all
FILE * fopen(const char * filename, const char * mode);

The file name is the complete name of the file... The mode can be;
"r" opens text file for reading
"w" creates text file for writing, it will discard the previous contents
"a" I think this is apend, which if I am not mistaken opens or creates text file, but you start at the end of the file
"r+" I think this is just update reading, though there are more rules to this, so I don't suggest it.
"w+" Again for update, don't suggest.
"a+" Same as a but update...