vector initialization

Chad Gibbons chad at lakesys.UUCP
Tue Jun 6 23:54:17 AEST 1989


...at the risk of being burned at the stake;

	After scanning a few books, I've been unable to find an answer 
either way to my question, so I must resort to the help of the net.
Question: is it possible to initialize a vector?

	I tried using the same syntax as an array of pointers, i.e.
		char *foo[] = { "one", "two", "three", NULL };
but this would not compile.  Since I am initializing it, it would seem an
array of pointers would suffice.  However, in the context of something
along these lines (from a command list vector):

typedef struct _com {
    char **words;
    int (*fcn)();
    short flags;
} COM;

...and then initializing the structure in another module by:

COM foo[] = {
    { "one", "two", "three", NULL }, do_num, 0,
    { "exit", "quit", NULL }, quit, 0
};

That would be nice, but something tells me it isn't C, or anything else
like it.  I may resort to allowing only a single word per structure, but
it would be more advantageous to use a list associated with a single
structure entry.

	Anyway to achive this?  Perhaps the actual structure definition
is the problem here, I'm not sure.
-- 
D. Chadwick Gibbons, chad at lakesys.lakesys.com, ...!uunet!marque!lakesys!chad



More information about the Comp.lang.c mailing list