Repositioning within files

You can use the following library functions to help you position within a memory or hiperspace memory file. See z/OS XL C/C++ Runtime Library Reference for more information on these library functions.

Using fseek() to seek past the end of a memory file extends the file using null characters. This may cause z/OS® XL C/C++ to attempt to allocate more storage than is available as it tries to extend the memory file.

When you use the fseek() function with memory files, it supports byte offsets from SEEK_SET, SEEK_CUR, and SEEK_END.

All file positions from ftell() are relative byte offsets from the beginning of the file. fseek() supports these values as offsets from SEEK_SET.

fgetpos(), fseek() with an offset of SEEK_CUR, and and ftell() handle ungetc() characters unless you have set the _EDC_COMPAT environment variable, in which case fgetpos() and fseek() do not. See Using environment variables for more information about _EDC_COMPAT. If in handling these characters, if the current position goes beyond the start of the file, fgetpos() returns the EOF value, and ftell() returns -1.

fgetpos() values generated by code from previous releases of the z/OS XL C/C++ compiler are not supported by fsetpos().