totn C Functions

C Language: fwrite function
(Write Block to File)

In the C Programming Language, the fwrite function writes nmemb elements (each element is the number of bytes indicated by size) from ptr to the stream pointed to by stream.

Syntax

The syntax for the fwrite function in the C Language is:

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

Parameters or Arguments

ptr
The array where the elements are copied from.
size
The size of each element in bytes.
nmemb
The number of elements to write.
stream
The stream to write to.

Returns

The fwrite function returns the number of elements written.

Required Header

In the C Language, the required header for the fwrite function is:

#include <stdio.h>

Applies To

In the C Language, the fwrite function can be used in the following versions:

  • ANSI/ISO 9899-1990

See Also

Other C functions that are noteworthy when dealing with the fwrite function: