Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

In C how would i write an array to a file

  1. Nov 20, 2008 #1
    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 im using ubuntu or windows
  2. jcsd
  3. Nov 20, 2008 #2


    User Avatar
    Science Advisor
    Homework Helper

    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.
  4. Nov 20, 2008 #3


    User Avatar

  5. Nov 29, 2008 #4
    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook