First C program
Frank Kolmann <[email protected]>
| Newsgroups | gmane.comp.lang.as400.c |
|---|---|
| Message-ID | <CAB-SQvhCnOLeSFgoGOfW7EcxD2aAbadZzv6AfVVWBL_TEZ0S=w@mail.gmail.com> |
Hi Barbara
Thank you, I have learnt some more.
I am using Jevgenis suggestion to pass pointers to pointers.
I have made fOpenFiles 'static', thanks for the warning.
Frank
> *From: Barbara Morris <bmorris@xxxxxxxxxx>
> *Date: Thu, 03 Apr 2014 13:31:44 -0400
>Rather than make the file pointers global,
>you could have the function just handle one file at a time,
>with the filename and open-mode as parameters, and returning the file
pointer.
>
>pf = fOpenFile (PFILENAME, "rr");
> ...
>
>static _RFILE *fOpenFile(const char *filename,
> const char *openmode,
> int rc)
> {
> _RFILE *f;
> f = _Ropen(filename, openmode);
> if (f EQ NULL)
> {
> printf("can't open file %s\n", PFILENAME);
> exit(rc);
> }
> return f;
> }
>
>Be careful to code "static" for any function that you want to be local to
the module.
>I would not use GLOBAL for this, since that would be very confusing, even
though it would work.
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.