#char (*tp[N])[] ?
06-Aug-93 05:10:09
Sb: #36224-#char (*tp[N])[] ?
Fm: Dale Larson 76702,654
To: Jeff Pratt 76057,3645
I'm guessing that you don't mean everything that you say. I think that
you want an array of pointers to strings (which are themselves arrays of
chars).
An array, X, of pointers to char *, is declared as char *X[y];, where "y"
is the length of the desired array. It absoultely doesn't matter how long
any of the strings are. This array is only going to take (y*sizeof(char
*)) no matter what any of the pointers point to. What this does is to
create an array of "y" pointers. If you haven't auto-initialized your
array (told the compiler what strings you want to be pointed to), you
could initialize it and use it something like this:
main()
{
char *X[3];
X[0] = "test";
X[1] = "this is";
X[2] = "a";
printf("%s %s %s.\n", X[1], X[2], X[0]);
}
Looking at your source:
First, don't put a declaration in a header. (There are two words I can
never remember to keep straight — one is where you tell the compiler
about the type of some variable you want to refernce, the other is where
you tell the compiler that *and* ask it to set aside memory for the
variable — I'm talking about the later.) You could have "extern char
*mt_fieldnames[]" in your .h, but you shouldn't have the rest there.
I don't get your #define of WHERE. I don't understand the syntax and I
don't understand what you are trying to do.
Dale Larson
– An Amiga Software Engineer with some time on his hands.