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

    a page on wiki has a good tutorial on C File IO, and a Google search give a lot result.
  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.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: In C how would i write an array to a file
  1. C file I/O (Replies: 3)

  2. C++ file i/o (Replies: 7)