PDA

View Full Version : In C how would i write an array to a file


j-lee00
Nov20-08, 11:22 AM
In C how would i create, open and write an array to a text file

The array is EeV[i],

does it make a difference if im using ubuntu or windows

mgb_phys
Nov20-08, 11:42 AM
fopen() to open the file fwrite() to dump the data fread() to get it back.
The only differenc eon windows is you have to add a 'b' in the fopen() call to specify binary, ie fopen(filename,"wb") to open a file for writing.

zyh
Nov20-08, 07:49 PM
a page on wiki has a good tutorial on C File IO, and a Google search give a lot result.
http://en.wikipedia.org/wiki/Fwrite#fwrite

dimensionless
Nov29-08, 08:54 AM
I like to create a memory block containing all the data and the file header, and then just write the whole block to my hard drive.