Why can't I do this?

P. T. Withington ptw at vaxine.UUCP
Tue Jan 17 03:01:48 AEST 1984


Well.  I got lots of replies to my query that told me I couldn't do what I
wanted to do because I was doing something illegal.  Well, I knew that.  The
compiler told me so.  I guess what I really should have asked is:  "How can I
do this"?  It seemed to me that there ought to be a way to initialize an array
of pointers to things other than char.  Two solutions were suggested:

1) Don't do it that way; declare it as a ?*n array (either implicity or
explicitly).  Which wastes the space I was trying to conserve.  (? is really
very large in my case and n ranges between 3 and 7.)

2) Declare a lot of useless 1-dim arrays followed by a declaration of the array
of pointers.  Which is more in the spirit of things, but since ? is so big
(see above) leads to a lot of unnecessary clutter and doesn't sound like C to
me.

I thought that maybe:

int *bar[] = {&{0, 1, 2, ...

would do, but my compiler doesn't like that either.  Of course, my ints are all
very small so I *could* say:

char *bar[] = {"\0\1\2", ...

Yuk!

Maybe it's just not important to worry about that many bytes any more.  Maybe
its something that just isn't done enough to create a hulluballoo over.

                                          -ptw



More information about the Comp.lang.c mailing list