Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about void pointer type casting.

Status
Not open for further replies.

isaisa

Programmer
May 14, 2002
97
IN
Hi all,
I am doubtful about the void pointer type casting.
As per my understanding of 'C', when one typecasts a veriable, the temp variable gets created and the operations are done based on the temp variable formed. The original variable is unaffected.
For example : int i = 10; (float)i;
The above two statements keeps the variable "i" intact by forming the new temp variable of type mentioend in the typecast bracket. Please correct me if i am interpretting typecasting in a wrong way.

If my understanding about explicit type cast is correct then i wanted to know about void pointer type casting.
LPVOID ptr_void; OR void *ptr_void;
struct test {int i; float f;}test1;
ptr_void = &test1;
struct test *ptr_test = (struct test *)ptr_void;

I wanted to know if the temp variable formed will be pointer to the said structure or the structure variable itself ????

Thanks in advance...

sanjay

 
Since you are using pointers, there is no temp var. created. You are dealing with original data directly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top