fseek(3C)
_________________________________________________________________
fseek function
Position a file to a specified byte.
_________________________________________________________________
Calling Sequence
#include <stdio.h>
FILE *fp;
long disp;
int mode, error, fseek();
error = fseek(fp, disp, mode);
where fp is a pointer to a FILE stream for an open file.
disp is a byte displacement.
mode uses disp as a byte offset from one of the
following:
0 beginning of file
1 current position
2 end of file
Description
Use the fseek function to position a file to a specified byte.
The include file stdio.h defines this function.
Returns
The function returns 0 in error if no error occurs, and -1
otherwise.
Related Functions
See also the lseek function described in the Programmer's
Reference for the DG/UX System (Volume 1).
Example
/* Program test.c for the fseek() function */
#include <stdio.h>
FILE *fp, *fopen();
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
fseek(3C)
char next;
long disp = 0, mode = 2;
int fseek();
main(argc, argv)
int argc;
char *argv[];
{
fp = fopen(argv[1], "r");
while (fseek(fp, disp, mode) == 0) {
next = getc(fp);
putchar(next);
disp--;
}
}
A call to the program test with its source code file as an
argument generates as output the reversed file
}
}
;--psid
;)txen(rahctup
;)pf(cteg = txen
{ )0 == )edom ,psid ,pf(keesf( elihw
;)"r" ,]1[vgra(nepof = pf
{
;][vgra* rahc
;cgra tni
)vgra ,cgra(niam
;)keesf int
;2 = edom ,0 = psid gnol
;txen rahc
;)(nepof* ,pf* ELIF
>h.oidts< edulcni#
/* noitcnuf )(keesf eht rof c.tset margorP */
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)