Figure 128. T1520ASP -- ILE C Source to Process a Database Record File in Arrival Sequence
/* This program illustrates how to copy records from one file to */
/* another file, using the _Rreadn(), and _Rwrite() functions. */
#include <stdio.h>
#include <stdlib.h>
#include <recio.h>
#define _RCDLEN 300
int main(void)
{
_RFILE *in;
_RFILE *out;
_RIOFB_T *fb;
char record[_RCDLEN];
/* Open the input file for processing in arrival sequence. */(1)
if ( (in = _Ropen("*LIBL/T1520ASI", "rr, arrseq=Y")) == NULL )
{
printf("Open failed for input file\n");
exit(1);
};
/* Open the output file. */2(
) if ( (out = _Ropen("*LIBL/T1520ASO", "wr")) == NULL )
{
printf("Open failed for output file\n");
exit(2);
};
/* Copy the file until the end-of-file condition occurs. */
fb = _Rreadn(in, record, _RCDLEN, __DFT);(3)
while ( fb->num_bytes != EOF )
{
_Rwrite(out, record, _RCDLEN);(4)
fb = _Rreadn(in, record, _RCDLEN, __DFT);
};
_Rclose(in);
_Rclose(out);
}
|
Notes:
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.