Open main menu

CDOT Wiki β

Changes

C/C++ FAQ

704 bytes added, 23:29, 23 September 2012
no edit summary
----
<br>
 
'''Q:''' Is this syntax for pointer casting and dereferencing *(int*)p for void* p equivalent to (*(int*)p)?
<br>
'''A:''' Yes, however the latter is generally more accepted due to readability.
<br>'''Submitted by:''' Team 6 <br><br>
 
'''Q:''' Why can't void* variables be dereferenced?
'''A:''' The pointer can't be dereferenced, because the compiler will not know how much of the memory is devoted to that particular value. For example if one has 8 bytes in memory with values in it, they are interpreted differently as int (2x 4 byte ints) and double (1x 8byte double). Without a data type the value cannot be determined therefore casting must be done first.
<br>'''Submitted by:''' Team 6 <br><br>