Is this ok??

Steve Summit scs at adam.mit.edu
Sat Mar 9 17:32:31 AEST 1991


In article <1991Mar08.191107.23161 at pilikia.pegasus.com> art at pilikia.pegasus.com (Art Neilson) writes:
>In article <DAVIS.91Mar6213546 at pacific.mps.ohio-state.edu> davis at pacific.mps.ohio-state.edu  (John E. Davis) writes:
...
>>void fm2(s)
>>char **s;
>      ^ here we go yet again, this parameter doesn't match
>        what you're trying to pass in from fm1().
>>{
>>    *s = "Hello\n";
>     ^ you can't do this.  s points nowhere.
>       besides, you need to do strcpy(s, "Hello"),
>       the way you are initializing *s is wrong.
...
>>      char *s;
>>      fm1(&s);
>           ^why are you passing "address of" s ?
>            s is already an address, remove the &.
>
>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.

Yes, it is important to make sure you understand what's going on
before you post.

The code posted by John Davis was correct, although it contained
several (perfectly legal) pointers to pointers which apparently
confused both a VMS compiler (thus John's original question) and
Arthur Neilson (thus these irrelevant criticisms).  The code
passes lint -hbxa with flying colors (i.e. no complaints about
argument mismatches) and runs correctly under any number of
compilers.

                                            Steve Summit
                                            scs at adam.mit.edu



More information about the Comp.lang.c mailing list