I requested help with a certain idea of mine on another forum, and they gave me code with this line in it: *((int*)lulz.data);
The question is, what does it do?
What I thought it meant was a pointer to lulz.data, where lulz.data is defined as an int. But I'm not sure. Can anyone clarify?
It might be better to post your code so we can see what your trying to do with it, but it looks like your trying to dereference lulz.data that you've casted to an int*.
What I'm trying to do is make a dynamic data type that changes type when needed with a function.
Someone on http://forum.palib.info/index.php?topic=6111.msg43109;topicseen#new posted that I should try using a struct and a switch case, but I would like, in layman's terms, what the above line does. Can you explain dereferencing?
//Ignore the weirdness, it's for a LOLCODE project.
I believe it is because the data is a void*, so they need to cast it as an int*, but then the want it dereferenced (to get the int that it is pointing at), which is why there is the * in front of the entire thing.
Put an integer variable name and an equals sign in front of the line of code you posted in your first post.
1 2 3
int foo;
foo = *((int*)lulz.data);
It is worth your time to check out the C++ Language Tutorial on this site http://www.cplusplus.com/doc/tutorial/
(particularly the section on Pointers).