[comp.lang.c] What's the difference between *thing and thing[]???

greyham@hades.OZ (Greyham Stoney) (08/21/89)

I seem to have been getting some real bizarre behaviour with C compilers
having trouble with pointer declarations when pointers are passed as
arguments to functions. It seems like I'm getting the same problems with a
couple of System-V compilers, and a cross-compiler we use at work, so it
looks like something I'm doing wrong.

The problem arises when I have something like:

char thing[] = "let's have a huge party";

rage(thing)
char	*thing;
{
	do_whatever.....
}

main()
{
	rage(thing);
}

This seems to cause unpredictable behaviour when thing is used in rage.
The problem seems to be solved by declaring 'thing' in 'rage()' to be:

char	thing[];

So..... can someone please tell me what is going on. I got the impression
that *thing and thing[] were interchangeable. Both are pointers to thing
aren't they?

If anyone can help, please reply via MAIL as my newsfeed isn't working
properly at present; post too if you like, but mail me a copy.

					thanks,  Greyham
-- 
/*  Greyham Stoney:    +61 2 428 6476     <- yes; that IS a phone number!
 *     greyham@hades.oz  - Ausonics, Lane Cove, Oz.
 */	"I wanna be an Engineer my friend, I wanna be an Engineer....."