Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!uupsi!sunic!enea!mla From: mla@enea.se (Mats L|fstr|m) Newsgroups: comp.lang.c Subject: Re: Is this ok?? Keywords: pointer initialization Message-ID: <2776@enea.se> Date: 9 Mar 91 23:21:38 GMT References: <1991Mar08.191107.23161@pilikia.pegasus.com> Distribution: comp Organization: Enea Data AB, Sweden Lines: 49 In article <1991Mar08.191107.23161@pilikia.pegasus.com> art@pilikia.pegasus.com (Art Neilson) writes: Lots of stuff deleted, I haven't time to comment on all of it, so I'll concentrate on just one item. I think my point will be clear enough... >> >>int main() >> { >> char *s; >> >> fm1(&s); > ^why are you passing "address of" s ? > s is already an address, remove the &. s isn't an address, it's a pointer, i.e. a variable *containing* an address. And the poor guy is trying to give the address of this pointer as an argument to fm1(). Which is perfectly legal and very usefull in some situations. As in this, for instance. What he wants to do, is to give s a good value, i.e. set it to point to a "string". In order to do so, he must give the address of the pointer (s) as an argument to fm1(). fm1() then has a chance to change the value of s. Some more lines deleted. > >You should really read your textbook before posting something like this >to the net. Any book worth it's salt will teach you not to make the >sort of mistakes you've made here. Maybe you should buy yourself a new textbook. :-) >-- >Arthur W. Neilson III | INET: art@pilikia.pegasus.com >Bank of Hawaii Tech Support | UUCP: uunet!ucsd!nosc!pilikia!art ---------------------------------------------------------------------------- International: Domestic: Mats Lofstrom Mats L|fstr|m ENEA Data AB ENEA Data AB Nytorpsvagen 5b Nytorpsv{gen 5b Box 232 Box 232 S-183 23 TABY 183 23 T[BY Phone: (+46) 8792 - 2500 Tel: 08 - 792 25 00 e-mail: mla@enea.se ----------------------------------------------------------------------------