Problem in compiling C program
Thomas Burrows <[email protected]> Wed, 19 Apr 2023 01:50:59 -0500
| Newsgroups | gmane.comp.lang.as400.c |
|---|---|
| Message-ID | <CANFrdV92GNMqQcPtc1o5t+eNOaF0JoKcwuAfr-EgqRsS5c9qpQ@mail.gmail.com> |
I pulled this program from the IBM C/C++ manual. Around page 412 or
so.
Have attached the manual. And a copy of the program I put into a text file.
Using NOTEPAD++ to edit my text.
Kind of stuck.
Thomas Burrows
mobile 469 693 2533
65 | _Rclose(pf);
66 | _Rclose(subf);
67 |
68 | } /*close of main routine */
69 |
70 | void init_subfile(_RFILE *pf, _RFILE *subf)
71 | {
72 | _RIOFB_T *fb;
73 | int i;
74 | pf_t record;
75 |
76 | /* Select the subfile record format. */
SEVERE==========> CZM0046 Syntax error.
77 |
78 | _Rformat(subf, "SFL");
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/c400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/c400-l.
C subfile program.txt
(text/plain, 1.8 KB)
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
/* This program illustrates how to use subfiles. */
#include <stdio.h>
#include <stdlib.h>
#include <recio.h>
#define LEN 10
#define NUM_RECS 20
#define SUBFILENAME "*LIBL/T1520DDG"
#define PFILENAME "*LIBL/T1520DDH"
typedef struct
{
char name[LEN];
char phone[LEN];
}
pf_t;
#define RECLEN sizeof(pf_t)
void init_subfile(_RFILE *, _RFILE *);
int main(void)
{
_RFILE *pf;
_RFILE *subf;
/* Open the subfile and the physical file. */
if ((pf = _Ropen(PFILENAME, "rr")) == NULL)
{
printf("can't open file %s\n", PFILENAME);
exit(1);
Working with File Systems and Devices 223
}
if ((subf = _Ropen(SUBFILENAME, "ar+")) == NULL)
{
printf("can't open file %s\n", SUBFILENAME);
exit(2);
}
/* Initialize the subfile with records from the physical file. */
init_subfile(pf, subf);
/* Write the subfile to the display by writing a record to the */
/* subfile control format. */
_Rformat(subf, "SFLCTL");
_Rwrite(subf, "", 0);
_Rreadn(subf, "", 0, __DFT);
/* Close the physical file and the subfile. */
_Rclose(pf);
_Rclose(subf);
}
void init_subfile(_RFILE *pf, _RFILE *subf)
{
_RIOFB_T *fb;
int i;
pf_t record;
/* Select the subfile record format. */
Rformat(subf, "SFL");
for (i = 1; i <= NUM_RECS; i++)
{
fb = _Rreadn(pf, &record, RECLEN, __DFT);
if (fb->num_bytes != EOF)
{
fb = _Rwrited(subf, &record, RECLEN, i);
if (fb->num_bytes != RECLEN)
{
printf("error occurred during write\n");
exit(3);
}
}
}
}