Hi,

I have been trying to figure out casting, and have a quick question I hope someone can help me with:

What exactly is the purpose of casting, like for int, char...etc...:
example:
int x = 5;
(char) x;

I am confused about this? what does it mean, and why is it needed??


Also, I keep seeing code where it mentions casting a pointer:
example:
(void *) something;

Could someone please explain what casting a pointer means and why it is needed??

Thanks a lot for any explanation! It is appreciated!