Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ftell(3S) — NEXTSTEP 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

lseek(2)

fopen(3S)

FSEEK(3S)  —  UNIX Programmer’s Manual

NAME

fseek, ftell, fgetpos, fsetpos, rewind − reposition a stream

SYNOPSIS

#include <stdio.h>

int fseek(FILE ∗stream, long int offset, int whence);

long int ftell(FILE ∗stream);

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

int fsetpos(FILE ∗stream, const fpos_t ∗pos);

void rewind(FILE ∗stream)

DESCRIPTION

Fseek sets the position of the next input or output operation on the stream. The new position is at the signed distance offset bytes from the beginning, the current position, or the end of the file, according as whence has the value SEEK_SET, SEEK_CUR, or SEEK_END.  Fseek undoes any effects of ungetc(3S).

Ftell returns the current value of the offset relative to the beginning of the file associated with the named stream. It is measured in bytes on UNIX; on some other systems it is a magic cookie, and the only foolproof way to obtain an offset for fseek.

Fgetpos stores the current value of the file position indicator for the stream pointed to by stream in the object pointed to by pos. The value stored contains unspecified information usable by the fsetpos function for repositioning the stream to its poisition at the time of the call to the fgetpos function. 

Fsetpos sets the file position indicator for the stream pointed to by stream according to the value of the object pointed to by pos, which must be value returned by an earlier call to fgetpos on the same stream.  A successful call clears the end-of-file indicator for the stream and undoes any effects of the ungetc function on the same stream. After call on an update stream, the next operation may be either input or output. 

Rewind(stream) is equivalent to: (void) fseek (stream, 0L, 0)

SEE ALSO

lseek(2), fopen(3S)

DIAGNOSTICS

Fseek, fgetpos, and fsetpos return −1 for improper or unsuccessful calls and stores an error code in errno, otherwise returns zero.

Ftell returns −1 for improper or unsuccessful calls and stores an error code in errno, otherwise returns the current value of the file position indicator for the stream.

ANSI C  —  June 23, 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026