Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!bionet!ames!uhccux!munnari.oz.au!murtoa.cs.mu.oz.au!otc!metro!ipso!natmlab!basser!ultima!hades!greyham From: greyham@hades.OZ (Greyham Stoney) Newsgroups: comp.lang.c Subject: What's the difference between *thing and thing[]??? Keywords: C, pointers, pain-in-the-neck, bizarre Message-ID: <370@hades.OZ> Date: 21 Aug 89 16:21:55 GMT Organization: Ausonics Pty Ltd, Sydney, Australia Lines: 38 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....."