How does this pointer cast address work
float f = 1.83;
unsigned int i = *( const unsigned int *) &f ;
How does this pointer cast address work
float f = 1.83;
unsigned int i = *( const unsigned int *) &f ;
> unsigned int i = *( const unsigned int *) &f ;
& - make a pointer of type float*
( const unsigned int *) - make believe that it's a pointer to a const unsigned int.
* - dereference it to get an unsigned int.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
this is & address.
why use const?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.