tdh@DRD.Com (Tom Haynes) (07/18/90)
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@apctrc.amoco.com. Whenever, Tom Haynes.
volpe@underdog.crd.ge.com (Christopher R Volpe) (07/18/90)
In article <1990Jul17.224910.20086@DRD.Com>, tdh@DRD.Com (Tom Haynes) writes: > int ared2bf(struct st_edit **, int, char ***, int *, int *); > int cischa(int, char *, int, int, char **); > char buf[SCREEN][COLS][MAX_SCREEN]; > char prefix[6][KEYS]; > int curr; > curr = 0; > : > : > cischa(pnlptr, "PREFIX", 0, SCREEN, prefix[curr]); * ^^^^^^^^^^^^ * * prefix[curr] is of type (char *) whereas the formal parameter * is of type (char **). Maybe you wanted "&prefix[curr]"??? * > ared2bf9EDIT, curr, buf, free, list); > ardrvr.c(63) : warning C4047: 'arguement' : different levels > of indirection * *You haven't shown the reference to 'arguement' * > ardrvr.c(63) : warning C4024: 'cischa' : different types : > parameter 5 * * The is the one I pointed out above (prefix[curr]). * > ardrvr.c(64) : warning C4047: 'arguement' : different levels > of indirection > ardrvr.c(64) : warning C4024: 'ared2bf' : different types : > parameter 3 * *Beats me, buf is of type (char ***), and that's what the formal parameter *wants. * Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com
karl@haddock.ima.isc.com (Karl Heuer) (07/19/90)
In article <9905@crdgw1.crd.ge.com> volpe@underdog.crd.ge.com (Christopher R Volpe) writes: >In article <1990Jul17.224910.20086@DRD.Com>, tdh@DRD.Com (Tom Haynes) writes: >> char buf[SCREEN][COLS][MAX_SCREEN]; > >Beats me, buf is of type (char ***), and that's what the formal parameter >wants. No, it isn't. buf is of type `char[SCREEN][COLS][MAX_SCREEN]', which (being an array type) will decay into `char (*)[COLS][MAX_SCREEN]', i.e. pointer to array of array of char. If every object being passed through this parameter has type `char (*)[COLS][MAX_SCREEN]', then you can declare the parameter to have that type. Otherwise, your best bet is to allocate `buf' at runtime using dope vectors, so that it really does have type `char ***'. Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint
tdh@DRD.Com (Tom Haynes) (07/19/90)
volpe@underdog.crd.ge.com (Christopher R Volpe) wrote: } > cischa(pnlptr, "PREFIX", 0, SCREEN, prefix[curr]); } * ^^^^^^^^^^^^ } * prefix[curr] is of type (char *) whereas the formal parameter } * is of type (char **). Maybe you wanted "&prefix[curr]"??? } * I tried that, along with &prefix[curr][0], both were no go. Error message was something like '& not allowed on struct/array'. } > ared2bf9EDIT, curr, buf, free, list); } } > ardrvr.c(63) : warning C4047: 'arguement' : different levels } > of indirection } * } *You haven't shown the reference to 'arguement' } * Arguement refers to, in this case _arguement_ 3, or buf. Sorry if I thought the way MSC reported errors was the only way. } * } *Beats me, buf is of type (char ***), and that's what the formal parameter } *wants. } * } } Chris Volpe } G.E. Corporate R&D } volpecr@crd.ge.com I agree, but since it doesn't compile, it suggests that I don't have a good grasp if the situation. Oh well, back to _C for the Living Dead_, available in all your local occult stores. Thanks, and whenever, Tom Haynes
dkeisen@Gang-of-Four.Stanford.EDU (Dave Eisen) (07/20/90)
In article <1990Jul19.112403.709@DRD.Com> tdh@drd.Com (Tom Haynes) writes: >volpe@underdog.crd.ge.com (Christopher R Volpe) wrote: >} > cischa(pnlptr, "PREFIX", 0, SCREEN, prefix[curr]); >} * ^^^^^^^^^^^^ >} * prefix[curr] is of type (char *) whereas the formal parameter >} * is of type (char **). Maybe you wanted "&prefix[curr]"??? >} * > >I tried that, along with &prefix[curr][0], both were no go. >Error message was something like '& not allowed on struct/array'. > Many compilers don't take &prefix[curr] when prefix[curr] is an array, you can use prefix + curr instead. But prefix + curr is still of type pointer to array of char, the formal paramter is of type pointer to pointer of char; the types still don't match. -- Dave Eisen Home: (415) 323-9757 dkeisen@Gang-of-Four.Stanford.EDU Office: (415) 967-5644 1447 N. Shoreline Blvd. Mountain View, CA 94043