Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!tikal!sigma!uw-nsr!uw-warp!cjsa!jeff From: jeff@cjsa.WA.COM (Jeffery Small) Newsgroups: comp.lang.c Subject: Problem initializing a structure Message-ID: <154@cjsa.WA.COM> Date: 14 Dec 88 18:27:31 GMT Organization: C. Jeffery Small and Associates - Woodinville, WA Lines: 61 Given the following sample test program: -- sample program ------------------------------------------------------- #include static char *menu[] = { "aaa", "bbb", "ccc", 0 }; typedef struct { char **mptr; char *item; } TEST; TEST X = { menu, 0 }; main() { X.item = menu[0]; (void) printf("\t\t%s %s %s %s\n", *menu, menu[0], menu[1], menu[2]); return(0); } -- end of program ------------------------------------------------------- If you compile and run this program you get the following results: aaa aaa bbb ccc as expected, confirming that *menu and menu[?] are pointers to chars. Now, what I actually want to do is to assign the value to X.item in the initialization statement rather than the assignment statement. So I make the following change to the program: ... TEST X = { menu, *menu }; -- or -- TEST X = { menu, menu[0] }; ... but when I attempt to compile this I get: > "z.c", line 10: illegal initialization and lint says: > (10) illegal initialization So my question is why doesn't this initialization work and what should I actually be doing? I am working on an AT&T 3B1 running OS3.51 (some hybrid of SYSV.2). Thanks for any help you may be able to offer. -- Jeffery Small (206) 485-5596 uw-beaver!uw-nsr!uw-warp C. Jeffery Small and Associates !cjsa!jeff 19112 152nd Ave NE - Woodinville, WA 98072 uunet!nwnexus