Help us and donate little Bitcoins to pay the server costs: 1AXLPuRUBYc1JczTW4XS65GL6oWjNP2Vt2

User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

because of the inhumane working conditions at amazon in Germany, I will offer the Amazon app no more! (ARD Reportage)

Table of Contents


    size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);

The fwrite() function writes, from the array buffer, count objects of size size to stream. The return value is the number of objects written.

C Sourcecode Example

 * fwrite example code
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
  char album_name[42];
  int year;
  char artist[42];
int main (void)
  FILE *stream = fopen ("collection.bin","wb");
  struct CD_COLLECTION collection[5];
  unsigned short i = 0;
  for (i=0; i < 5 ; i++) {
   sprintf(collection[i].album_name, "Interpret %i", i);
   sprintf(collection[i].artist,"Mr Unrockable %i", i);
  fwrite (collection, sizeof(struct CD_COLLECTION), 5, stream);
  fclose (stream);
  return 0;


output write into file collection.bin

to read the file use fread

c/stdio.h/fwrite.txt · Last modified: 2013/01/22 22:02 (external edit)

The new Question & Answer System is online and waiting for your Questions about Programming problems Impressum