Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>fwrite() write unformatted data to stream</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
fwrite()                 Write Unformatted Data to Stream

 #include   <stdio.h>

 int        fwrite(buffer,size,count,stream);
 char       *buffer;                     Pointer to data to be written
 int        size;                        Item size in bytes
 int        count;                       Max number of items to be written
 FILE       *stream;                     Pointer to file structure


    fwrite() writes up to 'count' items of data, each of length 'size'
    bytes, from 'buffer' to the output 'stream'.  If there is a file
    pointer associated with 'stream', it is incremented by the number of
    bytes actually written.

    Returns:    The number of data items actually written.  The number
                may be less than 'count' if an error occurs.

      Notes:    If 'stream' was open in text mode, each carriage-return
                is replaced with a carriage-return-line-feed pair.  This
                has no effect on the return value.

  -------------------------------- Example ---------------------------------

    The following statements open a file for appending and write the
    contents of a buffer.

          #include <stdio.h>

          FILE *stream;
          char buffr[128];

          main()
          {
              if ((stream = fopen("data.bak","a+"))!= NULL) {
                  .
                  .
                  .
                  fwrite(buffr,sizeof(char),128,stream);
               }
           }

See Also: fread() write()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson