fread()

NAME

fread(), fwrite() - binary stream input/output

SYNOPSIS

#include <stdio.h>

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

DESCRIPTION

The function fread(3) reads nmemb objects, each size(1) bytes long, from the stream pointed to by stream, storing them at the location given by ptr.

The function fwrite(3) writes nmemb objects, each size bytes long, to the stream pointed to by stream, obtaining them from the location given by ptr. The functions fread(3) and fwrite(3) advance the file position indicator for the stream by the number of bytes read or written.

RETURN VALUES

Fread(3) and fwrite(3) return the number of objects read or written. If an error occurs, or the end-of-file is reached, the return value is a short object count (or zero).

Because the function fread(3) does not distinguish between end-of-file and error, callers must use feof(3) and ferror(3) to determine which occurred.

The function fwrite(3) returns a value less than nmemb only if a write error has occurred.

ERRORS

Fread(3) can set errno to the following values:

[EBADF]
Stream is not a valid file or socket descriptor open for reading.
[EFAULT]
Ptr points outside the allocated address space.
[EIO]
An I/O error occurred while reading from the file system.
[EINTR]
Before any data arrived, a read from a slow device was interrupted by the delivery of a signal.
[EINVAL]
The pointer associated with stream was negative.
[EAGAIN]
The file was marked for non-blocking I/O, and no data were ready to be read.

Fwrite(3) can set errno to the following values:

[EBADF]
Stream is not a valid descriptor open for writing.
[EPIPE]
An attempt is made to write to a pipe that is not open for reading by any process.
[EFBIG]
An attempt was made to write a file that exceeds the process's file size limit or the maximum file size.
[EFAULT]
Part of the data to be written to the file points outside the process's allocated address space.
[EINVAL]
The pointer associated with stream was negative.
[ENOSPC]
There is no free space remaining on the file system containing the file.
[EIO]
An I/O error occurred while reading from or writing to the file system.
[EAGAIN]
The file was marked for non-blocking I/O, and no data could be written immediately.

SEE ALSO

read(2)

write(2)

500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@systemmanager.forsenergy.ru to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.