Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>fwrite</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
fwrite

Usage

   #include <stdio.h>
   size_t fwrite(const void *buffer,size_t sizelem, size_t n,FILE *fp);

   ANSI

Description

   The function fwrite writes n elements of sizelem bytes each pointed to by
   buffer to the stream fp.

Example 

   #include <stdio.h>
   #include <stdlib.h>
   #include <string.h>

   int main()
   {
       char *buffer;
       unsigned sizelem,n;
       FILE *fp;
       int wrtn;
       buffer = calloc(255,1);
       sizelem = 1;
       n = 255;
       fp = fopen("file.dat","a");
       strcpy(buffer,"\nSample data\n");
       wrtn = fwrite(buffer,sizelem,n,fp);
       free(buffer);
       return EXIT_SUCCESS;
   }

Return Value

   The function fwrite returns the number of complete elements actually
   written which may be less than n if an error occurred.

See Also

   fread, write



See Also: fread write

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