fwrite

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abuthalip
    New Member
    • Dec 2007
    • 2

    #1

    fwrite

    Hi,
    I'm using bulk write using the fwrite function and i'm writting the charachter array. i am getting some unwanted spaces written in the output. my output is variable length. how to elimate the spaces thru fwrite function. My array widht is 4000 and lenght is 50000.

    asciiz is a charachter array of lenght 4000

    asciiz data_to_write[50000];

    fwrite(data_to_ write,sizeof(as ciiz),50000,dat File);

    Thanks in advance,
    Abu
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Originally posted by abuthalip
    asciiz is a charachter array of lenght 4000

    asciiz data_to_write[50000];
    Please show me the definition of the asciiz type. What you arw showing here won't compile.

    Comment

    • abuthalip
      New Member
      • Dec 2007
      • 2

      #3
      Originally posted by weaknessforcats
      Please show me the definition of the asciiz type. What you arw showing here won't compile.
      struct {
      char name[4000];
      }asciiz;

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        You could just declare an array:
        [code=c]
        char data_to_write[50000][4000];
        [/code]

        Anyhow, the fwrite will write the entire 200MB in one swatch. If you have spaces or variable length output, then you need to calculate the amount of data to be written after eliminating the spaces.

        This will be a very time consuming process.

        Also, if the output is variable kength, how would you know how much to read back in?? Otherwise, your disc file will become a black hole.

        Comment

        Working...