C pointer problems in VMS.

Richard Harter g-rh at cca.CCA.COM
Fri Mar 18 13:55:19 AEST 1988


In article <12464 at brl-adm.ARPA> V053MF43 at ubvmsc.cc.buffalo.EDU (Mike Ayers) writes:
o	... with sundry problems
>char *wr(a)
>int a;
>{ body }

>main()
>{
		<------- char *wr() goes here, your code declares wr as
			 a function returning an int (the default if there
			 is no declaration.)
> printf(" %s ",wr(4));
>}

>main()
>{
> char b[12];

> b[0]='A';
> strcpy(((&b)+1),"rf!");

			The expression &b should be &b[0].  b is an array
			and is a pointer (sort of :-)).  You are passing
			a pointer to a pointer.  b[0] is the first element
			of b.  &b[0] points to it.

			I say 'sort of' because there are subtle differences
			between arrays and pointers in C.  Some people can
			explain the difference; others can explain trans-
			substantiation.  I shall attempt neither in a public
			forum.
> printf(" %s ",b);
>}
-- 

In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die.
	Richard Harter, SMDS  Inc.



More information about the Comp.lang.c mailing list