Problem : Why can't you dereference a void pointer?Whereas most pointers have a type associated with them, and thus a size, void pointers can point to anything. When a computer dereferences a pointer, it checks the type to see how many bytes forward from the address pointed to it needs to look. But with a void pointer, which has no specific byte size associated with it, the computer has no idea what to look at, nor would it know how to interpret the data even if it did know the size.
Problem : Given the function: void print_bit_int(int value); which takes an integer as a parameter and prints out its bit representation, write a line of code which prints out the bit representation for a float spark (you can assume that a float is the same size as an integer).print_bit_int(*((int*)(void*)&spark));
Problem : Write a function, memcmp(), which takes two void pointers and a length in bytes, and compares the memory at those two locations for that many bytes. It should return a non-zero value if the memory matches, and zero if the memory does not match.
Problem : What is wrong with the following code? How would you fix it with a cast?
Problem : What is wrong with the following code?