Array of pointers (in general)
Bob Calbridge
bobc at attctc.Dallas.TX.US
Mon Dec 4 12:35:14 AEST 1989
Most of what I learn of C is picked up by reading other people's code. I
know specifically that you can define an array of pointers to predefined
character strings by the code
char *text [] = {
"Stuff",
"More stuff",
"End of text"
};
My immediate need requires that I simply establish an array of pointers and
also declare the space to which the pointers point. The data area does not
need to have an initial content but must be reserved. Is this possible or
is it necessary to have a previously defined data area specified to which
the pointers are directed? Am I even being clear?
Example: I want 10 uninitialized structures defined but I want to reference
them through an array of pointers. Rather than give each structure a name
and declare the array like
struct entry *list [] = {
&S1, &S2, &S3, &S4
};
can I avoid having to declare the structures S1, S2, etc. elsewhere in the
program?
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
= I know it's petty.......... =
- But I have to justify my salary! -
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
More information about the Comp.lang.c
mailing list