You can use the following library functions to read information
from memory files; see
z/OS XL C/C++ Runtime Library Reference for more information
on these library functions.
- fread()
- fread_unlocked()
- fgets()
- fgets_unlocked()
- gets()
- gets_unlocked()
- fgetc()
- fgetc_unlocked()
- getc()
- getc_unlocked()
- getchar()
- getchar_unlocked()
- scanf()
- scanf_unlocked()
- fscanf()
- fscanf_unlocked()
- vscanf()
- vscanf_unlocked()
- vfscanf()
- vfscanf_unlocked()
The gets(), getchar(), scanf(), and vscanf() functions
read from stdin, which can be redirected to a memory or
hiperspace memory file.
You can open an existing file for read one or more times, even
if it is already open for write. You cannot open a file for write
if it is already open (for either read or write). If you want to update
or truncate a file or append to a file that is already open for reading,
you must first close all the other streams that refer to that file.
For memory files, a read operation directly after a write operation
without an intervening call to
fflush(),
fsetpos(),
fseek(), or
rewind() fails.
z/OS® XL C/C++ treats
the following as read operations:
- Calls to read functions that request 0 bytes
- Read requests that fail because of a system error
- Calls to the ungetc() function
You can set up a SIGIOERR handler to catch read or write
system errors that happen when you are using hiperspace memory files.
See Debugging I/O programs for more information.