Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!ames!amdahl!pyramid!leadsv!laic!nova!darin From: darin@nova.laic.uucp (Darin Johnson) Newsgroups: comp.sys.amiga Subject: Re: Struggling through the "C" Message-ID: <510@laic.UUCP> Date: 13 Apr 89 16:55:36 GMT References: <2570@ssc-vax.UUCP> <231@nlgvax.UUCP> <6542@cbmvax.UUCP> <17491@cisunx.UUCP> <6597@cbmvax.UUCP> Sender: news@laic.UUCP Reply-To: darin@nova.UUCP (Darin Johnson) Organization: Lockheed AI Center, Menlo Park Lines: 24 As an example of the difference between "char *a", and "char a[100]", here is a piece of code that bit me recently: put_args(xdr_wrapstring, &str) Where I had assumed str was a "char *", but instead, was really an array. The routine needed the ADDRESS of the string pointer, not the pointer. As such, the compiler gave me a rude warning - "thou shalt not take the address of an array!". This was on UNIX. I was surprised since I do this sort of stuff in VMS, where a temporary variable is created automatically (I can pass variables of the sort "&0", etc.). The fix was simple: register char *sp; ... intervening code ... sp = str; /* or instead, s = &str[0] */ put_args(xdr_wrapstring, &sp); Of course, if you pass an array or pointer as an argument to a routine, then inside the routine, you don't have a problem, since you can always take the address of the parameter - which is on the stack or in a temporary. Darin Johnson (leadsv!laic!darin@pyramid.pyramid.com) Can you "Spot the Looney"?