Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Quick c question

Name: Anonymous 2010-11-07 21:30

Do FILE* work directly with the address of the file in the harddrive or is the file loaded into the ram and the FILE* works with that?

I mean, if I were making a small database and wanted to use a FILE* (as a member of the struct I use for the database) to the next element of the database would the FILE* still point ot the same location if I close the file and open it later?

Name: Anonymous 2010-11-08 1:44

I mean, if I were making a small database and wanted to use a FILE* (as a member of the struct I use for the database) to the next element of the database would the FILE* still point ot the same location if I close the file and open it later?
Most definitely no. When you re-open the file, you will get a new FILE*, which may or may not be at the same memory address as the last one.

Do FILE* work directly with the address of the file in the harddrive or is the file loaded into the ram and the FILE* works with that?
None of the above? FILE* is an abstract handle. The operating system may (and does) cache different parts of the file in RAM, but this is all hidden away. You do not have access to this directly with the standard C API.

Most operating systems provide a non-standard way of doing something like this however, such as with mmap().

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List