Is this ok??

Mats L|fstr|m mla at enea.se
Sun Mar 10 09:21:38 AEST 1991


In article <1991Mar08.191107.23161 at pilikia.pegasus.com> art at 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 at 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 at enea.se
----------------------------------------------------------------------------



More information about the Comp.lang.c mailing list