Mail Archives: djgpp/1997/11/25/09:43:27
At 08.18 1997-11-25 -0500, you wrote:
>
>> >array == &array
>> This is NOT true. `&array' is a pointer to array, i.e. a pointer to the
>> pointer of the first element in the array.
>
>No, it is true. Even if they weren't the same, "&array" would be the
>right one, since it's a pointer, and "array" isn't a pointer - it's
>the whole array, like "int" is all 32-bits of an integer.
Okay, apparently I was wrong about this, since I always learned that the
array name was a pointer to the first element of the array. However, array
!= &array if you pass array to a function as I see it, so it doesn't seem
right to use &array if you want a pointer to the first element in the array.
#include <stdio.h>
char foo[10];
void func(char foo[])
{
printf("foo = %p, &foo = %p\n", foo, &foo);
}
int main(void)
{
strcpy(foo, "987654321");
func(foo);
return 0;
}
$ ./test.exe
foo = 8c98, &foo = 4c490
-- Peter Palotas alias Blizzar -- blizzar AT hem1 DOT passagen DOT se --
*****************************************************
* A brief description of DJGPP: *
* NEVER BEFORE HAS SO FEW DONE SO MUCH FOR SO MANY! *
*****************************************************
- Raw text -