L
Lynn McGuire
Why does this work with Visual C++ 2005?
char buffer [10000];
void * test5 = & buffer;
I would think the compiler would give an error
on "& buffer", because "buffer" is the memory
address of the first element in the array, and
you can't get a memory address of a memory
address, there is no such thing. Note that
test5 and buffer do point to the same memory
address in the VC++ debugger after execution of
that line of code.
We do get a compiler error on:
char * test3 = & buffer;
And the following code compiles correctly:
char * test4 = & buffer [0];
The only thing i can think is the compiler
treats "& buffer" as "& buffer [0]" in the
void * case, assuming that is what the
programmer wanted.
Thanks,
Lynn
char buffer [10000];
void * test5 = & buffer;
I would think the compiler would give an error
on "& buffer", because "buffer" is the memory
address of the first element in the array, and
you can't get a memory address of a memory
address, there is no such thing. Note that
test5 and buffer do point to the same memory
address in the VC++ debugger after execution of
that line of code.
We do get a compiler error on:
char * test3 = & buffer;
And the following code compiles correctly:
char * test4 = & buffer [0];
The only thing i can think is the compiler
treats "& buffer" as "& buffer [0]" in the
void * case, assuming that is what the
programmer wanted.
Thanks,
Lynn