C question -- pointer to array of characters
randy kunkee XNX MGR
kunkee at ficc.uu.net
Wed Oct 18 08:37:59 AEST 1989
Forget that you probably wouldn't want to do the following and
consider the declaration:
char (*foo)[];
This declares "foo" to be a pointer to an array of characters.
My question is, how can you get an assignment to "foo" without
the C compiler complaining about different levels of indirection
(ie. make "foo" point to real storage) without using a typecast?
For example:
main()
{
char (*foo)[];
char bar[20];
foo = bar;
}
Does not work (well, it works, but the compiler complains).
Is my C compiler broken?
To put it another way, is there a declaration of "bar" that will
make the above assignment compile silently, and which allocates
storage for characters?
--
Randy Kunkee
Ferranti International Controls Corporation
12808 W. Airport Blvd. Sugar Land, TX 77478
UUCP: uunet!ficc!kunkee ph: (713) 274-5132
More information about the Comp.lang.c
mailing list