In C how would i write an array to a file

  • Thread starter Thread starter j-lee00
  • Start date Start date
  • Tags Tags
    Array File
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 22K views
j-lee00
Messages
93
Reaction score
0
In C how would i create, open and write an array to a text file

The array is EeV,

does it make a difference if I am using ubuntu or windows
 
Physics news on Phys.org
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.
 
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.