About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: December 2006

URL: http://cxc.harvard.edu/ciao3.4/fseek.tm.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 3.4 fseek Context: slangrtl

Synopsis

Reposition a stream

Syntax

Integer_Type fseek (File_Type fp, Integer_Type ofs, Integer_Type whence

Description

The fseek function may be used to reposition the file position pointer associated with the open file stream fp. Specifically, it moves the pointer ofs bytes relative to the position indicated by whence. If whence is set to one of the symbolic constants 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.

The function return zero upon success, or -1 upon failure and sets errno accordingly.

Example

define rewind (fp) { if (0 == fseek (fp, 0, SEEK_SET)) return; vmessage ("rewind failed, reason: %s", errno_string (errno)); }

The current implementation uses an integer to specify the offset. One some systems, a long integer may be required making this function fail for very large files, i.e., files that are longer than the maximum value of an integer.

Hardcopy (PDF): A4 | Letter
Last modified: December 2006



The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.