Arrays and Files in C programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zenoba
    New Member
    • Oct 2008
    • 8

    Arrays and Files in C programming

    Can someone help me to put an array of characters into a text file.
    For example i have a[] = {a,b,c,d,e};
    and i have to put the contents that is a b c d into a text file.
    Can someone give me an idea of how the code should be in C programming?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Have a look at the fwrite() function or even the fprintf(fd, "%c") function.

    kind regards,

    Jos

    Comment

    • curiously enough
      New Member
      • Aug 2008
      • 79

      #3
      If you want the file to appear neat and readable always use the fprintf function.
      And you can print the charachters on the text file the same way you print them on the screen,exept that the parameters of fprintf differ from printf (fprintf(F,"%c ",a[i])).

      Comment

      Working...