Passing Multi-dimensional arrays to a function
Tom Haynes
tdh at DRD.Com
Wed Jul 18 08:49:10 AEST 1990
I have two problems, which I suspect are actually one. First,
let me lay down some groundwork:
In my header file, arayedit.h, I have:
:
:
#define SCREEN 11
#define COLS 6
#define MAX_SCREEN 11
#define KEYS 500
:
:
int ared2bf(struct st_edit **, int, char ***, int *, int *);
int cischa(int, char *, int, int, char **);
:
:
In my "main" program, actually a driver for my code,
ardrvr.c, I have:
:
:
char buf[SCREEN][COLS][MAX_SCREEN];
char prefix[6][KEYS];
int curr;
curr = 0;
:
:
cischa(pnlptr, "PREFIX", 0, SCREEN, prefix[curr]);
ared2bf9EDIT, curr, buf, free, list);
:
:
And, in ared2bf.c, I have:
int ared2bf(struct st_edit **EDIT, int base, char ***buf,
int *free, int *list)
{
:
:
Finally, in cischa.c, I have:
int cischa(int pnlptr, char *fldnam, int fstelm, int numelm,
char **string)
{
:
:
When I try and compile the above code, in MSC 5.1, and its
supporting functions, I get the following errors:
ardrvr.c(63) : warning C4047: 'arguement' : different levels
of indirection
ardrvr.c(63) : warning C4024: 'cischa' : different types :
parameter 5
ardrvr.c(64) : warning C4047: 'arguement' : different levels
of indirection
ardrvr.c(64) : warning C4024: 'ared2bf' : different types :
parameter 3
Where lines 63 and 64 are the two lines that call the functions
cischa and ared2bf in ardrvr. Of course, these errors repeat
themselves for each of the calls that I have in ardrvr.
The questions that I have, is: How am I supposed to pass
my multidimensional arrays to a function. I have a 2x2
character string, buf, and an array of charcter strings,
prefix. With buf, I want to pass the whole array, and with
prefix, only that from index curr on. How do I accomplish
this amazing feat, which I, of course %\), think that I
am doing correctly with my implementation.
Also, instead of saying
:
char buf[SCREEN][COLS][MAX_SCREEN];
I would like to say,
:
char buf[SCREEN][cols][MAX_SCREEN];
where cols is an int that I have passed into ardrvr, and
is application dependent. As it is, COLS is application
independent, just change the #define, but two different
calls, with varying column (COLS) length is not permissable.
How do I go about coding this?
I want to personally thank each and every one of you
who answers, or even thinks about my problems. I read
this group, so either post it here or email me directly
at ztdh0a at apctrc.amoco.com.
Whenever,
Tom Haynes.
More information about the Comp.lang.c
mailing list