Dear Salem,
At risk of abusing your generosity, I'm going to pester you with another question. Well actually, two.
The first one is a request for a good C book recommendation. Something not geared toward beginners, and that does not shy away from explaining the low level stuff and details of what is going on behind the scenes.
I own K&R's The C Programming language and although I admit I haven't read it from cover to cover but rather use it as a reference manual, consulting it when I want to learn about a topic, I find it's depth lacking in several subjects. One example being the topic of my other thread, variadic arguments. I had to learn about this by using the internet.
The other question relates to typecasting. This is one of those subjects I'd like to study in detail to really understand what is going on at a deeper level. Specifically pointer typecasting.
I can do this just fine:
Code:
void *vptr;
vptr = (int*)45;
Yet In other circumstances, I get a warning about a cast to pointer from integer of different size, which I "solve" by casting to long. Why not here? What is different in this particular case?
More importantly, why the above works and yet this doesn't:
Code:
void *vptr;
vptr = (float*)4.5f; // error: cannot convert to a pointer type
Finally this is OK:
Code:
void *ptr;
int *iptr;
float *fptr;
*iptr = 45;
*fptr = 4.5f;
vptr = iptr;
vptr = fptr;