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 6.0 - <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>

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


    fwrite() writes data to the output 'stream'.  Up to 'count' items of
    data, each of length 'size' bytes, are written from 'buffer' to
    'stream', and the position of any file pointer associated with
    'stream' is increased by the number of bytes actually written.

    Returns:    The number of data items actually written; less if an
                error occurs. The return value is not affected for a
                'stream' opened in text mode, even though each carriage-
                return is replaced with a carriage-return-line-feed pair.

   -------------------------------- 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