ILE C/C++ Programmer's Guide

Data Management Stream Files and ILE C I/O Operations

C language onlyThe C International Standard 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 ISO C are stream operations.

On the iSeries Data Management system:

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 either one character at a time or one record at a time.

Because 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.

Avoiding Positioning Problems in the File

Because 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.

Caution:

Using the fopen() Function

The format of fopen() is:


#include <stdio.h>
FILE *fopen(const char *filename, const char *mode);

The mode variable is a character string that consists of an open mode which may be followed by keyword parameters. The open mode and keyword parameters must be separated by a comma or one or more blank characters.

Note:
For information about the recln parameter, see Dynamic Stream File Creation.

Using the open() member Function



Create an input, output, or input/output file stream and then link to a file. Use the open() member function of the file stream class to link a file stream with a file. The format of the open() member function is:

void ifstream::open(const char *filename, openmode mode=ios::in);
void ofstream::open(const char *filename, openmode mode=ios::out|ios:trunc);
void fstream::open(const char *filename, openmode mode);


[ Top of Page | Previous Page | Next Page | Table of Contents ]