[Courses] Re: pointers, array's, and sizeof()

coldfire rolick571 at duq.edu
Sun Feb 3 14:26:48 EST 2002


> wrong wrong.
> it is only in function parameters out of convenience that the compiler
> when it sees char a[] for example, will  treat it as  if it was char a*;
> <-- notice will be treated not converted...
> and thats only in function parameters !!

<huge ass snip>

are we discussing purely C?  or C++?  if C++ ...

        int a[5] = {1, 2, 3, 4, '\0'};
	cout << a << endl;
        cout << *a << endl;

run the above code:

	# ./a.out
	0xbffff788
	1

ok, the formal definition of a pointer?  "a pointer stores an address in
memory."  as indicated, 'a' is merely a pointer.  hence the pointer
notation i used in a previous email.  *(a+0), *(a+1), *(a+2), etc. will
print the contents of the array.


coldie




More information about the Courses mailing list