![]() Chapter Contents |
![]() Previous |
![]() Next |
| kseek |
| Portability: | SAS/C extension |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| EXAMPLE | |
| RELATED FUNCTIONS | |
| SEE ALSO |
| SYNOPSIS |
#include <lcio.h> int kseek(FILE *f, int pos);
| DESCRIPTION |
The
kseek
function repositions the stream associated with the
FILE
object addressed by
f
, as specified
by the value of
pos
, and releases control
of any current record. The
pos
value must
be either
SEEK_SET
,
SEEK_CUR
, or
SEEK_END
. (These constants
are defined in
<stdio.h>
.) Each of these
values refers to a specific location in the file, as follows:
SEEK_SET
|
refers to the start of file. |
SEEK_CUR
|
refers to the current file position. |
SEEK_END
|
refers to the end of file. |
If the current record is read for update, the record
is released and is read for update by another
FILE
object. Even though
kseek
with
pos
value
SEEK_CUR
causes no change in the file's positioning, it is still useful to
release control of the current record.
| RETURN VALUE |
The
kseek
function returns 0 if successful, or a negative value if an error
occurred.
| EXAMPLE |
This example retrieves the last record in a VSAM file:
#include <lcio.h>
int getlast(FILE *f, void *buf)
{
int length;
rc = kseek(f, SEEK_END);
if (rc < 0) return rc; /* in case it fails */
/* Retrieve backwards from EOF. */
length = kretrv(buf, NULL, K_BACKWARDS, f);
return length;
}
| RELATED FUNCTIONS |
| SEE ALSO |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.