From 82ba818ff456bcd6d56a06226e3f27e98fbb55c3 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 14 Aug 2025 22:58:58 -0500 Subject: removing all downloaded devdocs files --- devdocs/c/io%2Ffwrite.html | 59 ---------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 devdocs/c/io%2Ffwrite.html (limited to 'devdocs/c/io%2Ffwrite.html') diff --git a/devdocs/c/io%2Ffwrite.html b/devdocs/c/io%2Ffwrite.html deleted file mode 100644 index 35104178..00000000 --- a/devdocs/c/io%2Ffwrite.html +++ /dev/null @@ -1,59 +0,0 @@ -

fwrite

Defined in header <stdio.h>
size_t fwrite( const void* buffer, size_t size, size_t count,
-               FILE* stream );
-
(until C99)
size_t fwrite( const void* restrict buffer, size_t size, size_t count,
-               FILE* restrict stream );
-
(since C99)

Writes count of objects from the given array buffer to the output stream stream. The objects are written as if by reinterpreting each object as an array of unsigned char and calling fputc size times for each object to write those unsigned chars into stream, in order. The file position indicator for the stream is advanced by the number of characters written.

-

If an error occurs, the resulting value of the file position indicator for the stream is indeterminate.

-

Parameters

- - - - -
buffer - pointer to the first object in the array to be written
size - size of each object
count - the number of the objects to be written
stream - pointer to the output stream

Return value

The number of objects written successfully, which may be less than count if an error occurs.

-

If size or count is zero, fwrite returns zero and performs no other action.

-

Example

#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
- 
-enum { SIZE = 5 };
- 
-int main(void)
-{
-    double a[SIZE] = {1, 2, 3, 4, 5};
-    FILE* f1 = fopen("file.bin", "wb");
-    assert(f1);
-    size_t r1 = fwrite(a, sizeof a[0], SIZE, f1);
-    printf("wrote %zu elements out of %d requested\n", r1, SIZE);
-    fclose(f1);
- 
-    double b[SIZE];
-    FILE* f2 = fopen("file.bin", "rb");
-    size_t r2 = fread(b, sizeof b[0], SIZE, f2);
-    fclose(f2);
-    printf("read back: ");
-    for (size_t i = 0; i < r2; ++i)
-        printf("%0.2f ", b[i]);
-}

Output:

-
wrote 5 elements out of 5 requested
-read back: 1.00 2.00 3.00 4.00 5.00

References

See also

- - - -
-
(C99)(C11)(C11)(C11)(C11)
prints formatted output to stdout, a file stream or a buffer
(function)
writes a character string to a file stream
(function)
reads from a file
(function)
C++ documentation for fwrite
-

- © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
- https://en.cppreference.com/w/c/io/fwrite -

-
-- cgit v1.2.3