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

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 code for a proxy
I was wondering which function I could use to create an online proxy tool. I was thinking cURL would

printing links
Hi every1

i am connecting to a table in sql and the looping through with a while ($ var = my

Help with search.php
Hello All

I need the search engine on a site I am building at the moment to display the searc

frame help
on the bottom frame is menu.html

Code: <body><form action='link.php' met

form problem
below in the form action, i've put "test.php?w=$sw&h=$sh" but when i input the for

Need understanding of this bit of code
Code: <?php
// WHERE clause filters
$arrSQLFilters = array();

//

To change the name of label on SAP screen XK02.
Hi All,

Can one suggest me how to change the label of an input field of a sap standard s

what business processes?
Hi,

A general question. What business processes (like OTC - Order to Cach, P2P, R2R etc)

values not being entered into table
hi. I;ve created a form, so that when a user enters data into it, it gets added to a table in a data

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