I don't know enough of C yet. I know the very basics, string, date handling, methods etc all coming from C# online courses. But not enough to understand yet on file structures, reading, writing etc. Bouncing a head and I find it better to learn hands on vs watching videos and reading it in guides. Just keying it in and seeing it process. I have this code insert from one of IBM manuals but I don't follow the _Read syntax. And how to read/open a 2nd file, to grab the information from one record. or to update an existing record etc etc.
**edit**
The forum is not liking my copy/paste of source code. Updating here in a second.
Code:
/* 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. */
if ( (in = _Ropen("*LIBL/T1520ASI", "rr, arrseq=Y")) == NULL )
{
printf("Open failed for input file\n");
exit(1);
};
/* Open the output file. */
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);
while (fb->num_bytes != EOF )
{
_Rwrite(out, record, _RCDLEN);
fb = _Rreadn(in, record, _RCDLEN, __DFT);
};
_Rclose(in);
_Rclose(out);
}