Click here to Skip to main content
15,903,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I'ved came accross the following problem :

I have a variable
IntPtr pointer
to which I know that I have assigned a point structure ( x and y as floats ) .
I need to get the x value.
If I try to write x=pointer->x I get : "The * and -> operators must be applied to a pointer".
How could I get the value of pointer->x ?

Thanks in advance !
Posted

You first need to create a pointer to a point structure and cast your pointer object to it, then you can access the structure contents through the point reference. Something like:
IntPtr pointer = ...// your initialization here
Point* pt = (Point*)pointer;
float fx = pt->x;

I may be wide of the mark here but your subject line and tag gives very few clues as to what language you are using (i.e C++, C++/CLI, C#).
 
Share this answer
 
I believe you may have to use syntax like this. Like John, it has been a very long time since I've done work in C++, so I might just be providing useless info, but on the off chance that I'm right...
*pointer.x
or
((point)*pointer).x
 
Share this answer
 
It's been a while since I did any C++, but try pointer.x
 
Share this answer
 
Comments
Peter_in_2780 22-Nov-10 21:36pm    
It has indeed been a while! pointer->member is good, as is struct.member :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900