1. When performing file write, is disk accessed every time a file write is made or chunks of memory blocks are written at a time?
Not. Your output is not written until the output buffer is full. You can force write with fflush to clear output streams, causing an immediate write, but otherwise the output is buffered.
other 1. Will it improve performance if I'll take output of heap in an array of say size 1024 or may be more and then perform a write at once?
If you do not exhaust the heap, then no, you will not get significant performance by pushing the storage on the stack, etc. Buffering is always preferable, but if you save all the data in an array and then call write, you still have an output buffer of the same size you are dealing with.
source share