ILE C/C++ Programmer's Guide

Opening Binary Stream Files (character at a time)

To open an iSeries Data Management file as a binary stream file for character-at-a-time processing, use fopen() with any of the following modes:

Notes:

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

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

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

The valid keyword parameters are:

If you specify the type parameter the value must be memory for binary stream character-at-a-time processing.

Note:
The memory parameter identifies this file as a memory file that is accessible only from C programs. This parameter is the default and is ignored.

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

Example:

The following example illustrates how to open a binary stream file.

Figure 89. ILE C Source to Open a Binary Stream File




#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *fp;
/* Open an existing binary file. */
if (( fp = fopen ( "MYLIB/TEST(MBR)", "wb+" ) ) == NULL )
{
printf ( "Cannot open file\n" );
exit ( 1 );
}
printf ("Opened the file successfully\n");

/* Perform some I/O operations. */

fprintf (fp, "Hello, world");

fclose ( fp );
return 0;
}
Note:
You can read, write to, or update any binary stream files that are open for character-at-a time processing.


To open an iSeries Data Management file as a binary stream file for character-at-a-time processing, use the open() member function with ios::binary as well as any of the following modes:


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