Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo 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>

 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 up to 'count' items of data, each of length 'size'
    bytes, from 'buffer' to the output 'stream', at the location of the
    current file pointer, if appropriate.  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