-
Pointer confusion...
I wrote some sample code in VC++ .net and it involved pointers. To set the address of the pointer I had to do this:
Code:
int *a;
a = 0x00C000;
and use it like this
Code:
int iVal;
iVal = *a;
I thought using the asterisk in front of the pointer would make it return the address, or you could set the address that way. Wasn't it the other way around in VC++6?
Wasn't it like this in VC++6:
Code:
int *a, iVal;
*a = 0x00C000;
iVal = a;
-
>I thought using the asterisk in front of the pointer would make it return the address
Using the asterisk is called dereferencing, and it means that you are returning the contents of the address that the pointer points to:
Code:
#include <iostream>
int main ( void )
{
int x = 10,
*p = &x;
std::cout<<"x is "<< x
<<"\n*p is "<< *p
<<"\np is "<< p <<"\n";
return 0;
}
I'm not sure what kind of insane changes the .NET framework requires of C++, but it doesn't sound standard to me.
-Prelude