void* and sizeof()


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

Using void* and sizeof is it possible to get the value of the object ?

Did you know?Explore Trending and Topic pages for more stories like this.
I understand that dereferencing a void pointer is not directly possible. Is there a way (like casting) or something else to get the value of the object.

The problem is I wouldn't know the type of the object to cast to, I would only know the size of the object and a void pointer to the object.

something similar to what qsort does in stdlib.h, using merely the void pointer and sizeof, I think it manages to access the object, otherwise wouldn't be able to sort it.

Below shown is an example in which inside the function f1, I am suppose to access the object.

Code: class ClassA{};//Inside f1, I have to access the value of the object that pPtr1 points tovoid f1(void* pPtr1, const int pSizeOfObj){}int main(){ ClassA objA; f1(&objA, sizeof(objA)); return(0);}Thanks,
No comments posted yet

Your Answer:

Login to answer
324 Like 33 Dislike
Previous forums Next forums
Other forums

Best way to read this text file.
Hi.I am planning to make a small application in C# to convert the players from Football manager 2010

login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php

IS this code correct
The reason i ask is everything underneath it appears to be alink as well, tis blimmin annoying

grouping within a foreach?
hello all,

I currently have a list of products spit out from my db via a foreach loop. Right

Get last modified date of web page
Hai All,

In php how can i get last modified date of a give web page . I have tried to g

php mysql query from input textbox
Hi,

I have a text box, in that i have given the mysql query. I can able to get the query in v

apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?

modifying a property of an object from a different class
I have 2 classes:
- Math
- Distance

in my math class, I have this line:
$distance =

Is there a way to override built in php functions without APD?
I am trying to use the
rename_function()
override_function()
options that are built into

php global variable
how can we create global variable so we can use its value in any form.. Please give example to

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash