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

use an array from 1 class in a second class
I have a class that adds data to an array

Then I have a second class and I need to check if t

turning an array into a string then poping it into a db
Hi im just wondering how you get a requested array into a single string then pop it into the db so f

ereg_replace in Wordpress
Heya - so I'm working on this site: http://world-of-smiles.theportlandco.com/new-patients

The

Select all entries from database that include a phrase
I have a database of clubs - one of the categories is meeting time and place
I would like to have

Format timestamp from mysql
When I tried this:
Code: date("m/d/Y H:i A", $row['timestamp'])
I got 12/31/1969 18:

Setting condidtions for an input box
Hi all,

I would like to set a condition in a txt box that says the number a user enters has t

User feedback after MySQL query has been executed
Hi all, I've just registered on PHPFreaks because I've got a question that I simply can't work out b

Content-Disposition: attachment; filename=... not working as i thought it should
taken the following code from the php.net site the script is not working.

what is not happeni

I face problems to extract data from one table and insert it in another one
Hi,

For modifications, I have to extract data from one table and insert it in another one

PHP switch function help
Hi, I am trying to create a search function for a directory website. On the search function on html

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