Is the file loaded in RAM when i open the file in write mode?

Viewed 132

Suppose I have a empty file. Now the file is opened (let's assume i am using c language) Then my question is:-

Is the file loaded in RAM?

What happens if i write data in the file whose size is greater than size of RAM? Is the data successfully written in the file or not( since the size of data is greater than RAM) ?

1 Answers

What happens if i write data in the file whose size is greater than size of RAM?

The size of a file is not limited by C to the RAM memory space available.

Is the file loaded in RAM?

Usually a portion is loaded in RAM on a as needed basis, but that is an implementation detail and should not be expected to limit file size.

Is the file loaded in RAM when i open the file in write mode?

Usually not, but that is an implementation detail and should not be expected to limit file size.

Is the data successfully written in the file or not( since the size of data is greater than RAM) ?

Again the size of RAM is not a usual concern when writing to a file. I/O errors may be detected per each I/O command like from the return value of fprintf(). Success in final writing data to a file is reported on fclose(). Before that, that data may be partially written. Research fflush() to help insure select partial data is written before fclose().

Related