-->

Previous | Table of Contents | Next

Page 927

SYNOPSIS


#include <stdio.h>

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

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

DESCRIPTION

The function fread reads nmemb elements of data, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr.

The function fwrite writes nmemb elements of data, each size bytes long, to the stream pointed to by stream, obtaining them from the location given by ptr.

RETURN VALUE

fread and fwrite return the number of items successfully read or written (that is, not the number of characters). If an error occurs, or the end-of-file is reached, the return value is a short item count (or 0).

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

SEE ALSO

feof(3), ferror(3), read(2), write(2)

STANDARDS

The functions fread and fwrite conform to ANSI C3.159-1989 ("ANSI C").

BSD Man Page, 17 May 1996

frexp

frexp—Converts floating-point number to fractional and integral components

SYNOPSIS


#include <math.h>

double frexp(double x, int *exp);

DESCRIPTION

The frexp() function is used to split the number x into a normalized fraction and an exponent that is stored in exp.

RETURN VALUE

The frexp() function returns the normalized fraction. If the argument x is not 0, the normalized fraction is x times a power of 2, and is always in the range 1 ¦2 (inclusive) to 1 (exclusive). If x is 0, the normalized fraction is 0, and 0 is stored in exp.

CONFORMS TO

SVID 3, POSIX, BSD 4.3, ISO 9899

SEE ALSO

ldexp(3), modf(3)

GNU, 6 June 1993

fgetpos, fseek, fsetpos, ftell, rewind

fgetpos, fseek, fsetpos, ftell, rewind—Reposition a stream

Page 928

SYNOPSIS


#include <stdio.h>

int fseek(FILE *stream, longo ffset, int whence);

long ftell(FILE *stream);

void rewind(FILE *stream);

int fgetpos(FILE *stream, fpos_t *pos);

int fsetpos(FILE *stream, fpos_t *pos);

DESCRIPTION

The fseek function sets the file position indicator for the stream pointed to by stream. The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the start of the file, the current position indicator, or end-of-file, respectively. A successful call to the fseek function clears the end-of-file indicator for the stream and undoes any effects of the ungetc(3) function on the same stream.

The ftell function obtains the current value of the file position indicator for the stream pointed to by stream.

The rewind function sets the file position indicator for the stream pointed to by stream to the beginning of the file. It is equivalent to


(void)fseek(stream, 0L, SEEK_SET);

except that the error indicator for the stream is also cleared. (See clearerr(3).)

The fgetpos and fsetpos functions are alternate interfaces equivalent to ftell and fseek (with whence set to SEEK_SET), setting and storing the current value of the file offset into or from the object referenced by pos. On some non-UNIX systems, an fpos_t object may be a complex object, and these routines might be the only way to portably reposition a text stream.

RETURN VALUE

The rewind function returns no value. Upon successful completion, fgetpos, fseek, and fsetpos return 0, and ftell returns the current offset. Otherwise, _1 is returned, and the global variable errno is set to indicate the error.

ERRORS

EBADF The stream specified is not a seekable stream.
EINVAL The whence argument to fseek was not SEEK_SET, SEEK_END, or SEEK_CUR.

The function fgetpos, fseek, fsetpos, and ftell might also fail and set errno for any of the errors specified for the routines fflush(3), fstat(2), lseek(2), and malloc(3).

SEE ALSO

lseek(2)

STANDARDS

The fgetpos, fsetpos, fseek, ftell, and rewind functions conform to ANSI C3.159-1989 (ANSI C).

BSD Man Page, 29 November 1993

ftime

ftime—Returns date and time

SYNOPSIS


#include <sys/timeb.h>

int ftime(struct timeb *tp);

Page 929

DESCRIPTION

Return current date and time in tp, which is declared as follows:


struct timeb {

time_t time;

unsigned short millitm;

short timezone;

short dstflag;

};

RETURN VALUE

This function always returns 0.

NOTES

Under Linux, this function is implemented in a compatibility library instead of in the kernel.

CONFORMS TO

Version 7, BSD 4.3

Under BSD 4.3, this call is obsoleted by gettimeofday(2).

SEE ALSO

time(2)

Linux, 24 July 1993

ftok

ftok—Converts a pathname and a project identifier to a System V IPC key

SYNOPSIS


#include <sys/types.h>

#include <sys/ipc.h>

key_t ftok (char *pathname, char proj);

DESCRIPTION

The function converts the pathname of an existing accessible file and a project identifier into a key_t type System V IPC key.

RETURN VALUE

On success, the return value will be the converted key_t value; otherwise it will be _1, with errno indicating the error as for the stat(2) system call.

BUGS

The generated key_t value is obtained by stating the disk file corresponding to pathname in order to get its i_node number and the minor device number of the filesystem on which the disk file resides, then by combining the 8-bit proj value along with the lower 16 bits of the inode number with the 8 bits of the minor device number. The algorithm does not guarantee a unique key value. In fact,

Previous | Table of Contents | Next