Interview Questions

Using Stream and Record I/O Functions with iSeries Data
Management Files

This chapter describes how to open, write, read, and update:

  • Text stream files
  • Binary stream files

The American National Standards Institute (ANSI) defines a C language stream file as a sequence of data that is read and written one character at a time. All I/O operations in ANSI C are stream operations.

On the iSeries Data Management system, all files are made up of records. All I/O operations at the operating system level are carried out a record at a time, using data management operations.

The ILE C/C++ run-time library allows your program to process stream files as text stream files or as binary stream files. Text stream files process one character at a time. Binary stream files process one character at a time or one record at a time. Since the iSeries Data Management system carries out I/O operations one record at a time, the ILE C/C++ library simulates stream file processing with OS/400 records. Although the ILE C/C++ library logically handles I/O one character at a time, the actual I/O that is performed by the operating system is done one record at a time.

Note: Since the iSeries Data Management system carries out I/O operations one record at a time, using system commands such as OPNQRYF together with stream I/O operations on the same file may cause positioning problems in the file your program is processing.Do not mix the use of ILE C/C++ extensions for record I/O and stream file functions on the same file as unpredictable results can occur. Avoid using system commands that logically work with records instead of characters in programs that contain stream I/O operations.

Record Files

The ILE C library provides a set of extensions to the ANSI C definition for I/O. This set of extensions, referred to as record I/O, allows your program to perform I/O operations one record at a time.

The ILE C record I/O functions work with all the file types that are supported on the iSeries system.

Each file that is opened with _Ropen() has an associated structure of type _RFILE. The <recio.h> header file defines this structure. Unpredictable results may occur if you attempt to change this structure.

Different open modes and keyword parameters apply to the different iSeries Data Management system file types.“Using Externally Described Files in Your Programs”, “Using Database Files and Distributed Data Management Files In Your Programs” and “Using Device Files in Your Programs” provide information on each file type and how to open a record file using _Ropen().

Note: There is no equivalent function provided by the C++ run-time library.

Stream Files

On the iSeries Data Management system, a stream is a continuous string of characters.

iSeries Data Management Records Mapping to an ILE C Stream File

The ILE C compiler allows your program to process stream files as text stream files or as binary stream files. See “Text Streams” and “Binary Streams”.


Pragna Meter
Next Chapter  
e-University Search
Related Jobs