ILE C/C++ Programmer's Guide

Opening Text Stream Files

To open an iSeries system file as a text stream file, use fopen() with one of the following modes:

Notes:

  1. The number of files that can be simultaneously opened by fopen() depends on the amount of the system storage available.

  2. The fopen() function open modes also apply to the freopen() function.

  3. If the text stream file contains deleted records, the deleted records are skipped by the text stream I/O functions.

The valid keyword parameters are:

If you specify a mode or keyword parameter that is not valid on fopen(), errno is set to EBADMODE, and NULL is returned.

Example:

The following example illustrates how to open a text stream file. Library MYLIB must exist. The file TEST is created for you if it does not exist. The mode w+ indicates that if MBR does not exist, it is created for update. If it does exist, it is cleared.

Figure 84. ILE C Source to Open an ILE C Text Stream File




#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *fp;
/* Open a text stream file. */
/* Check to see if it opened successfully */
if (( fp = fopen ( "MYLIB/TEST(MBR)", "w+") ) == NULL )
{
printf ( "Cannot open MYLIB/TEST(MBR)\n" );
exit ( 1 );
}

printf ( "Opened the file successfully\n" );

/* Perform some I/O operations. */

fclose ( fp );
return 0;
}
Note:
You can read, write to, or update any text stream file that is open for processing.



To open an iSeries system file as a text stream file, use the open() member function with the following modes:


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