num is of type 'int'
&num is the address of num, which is of type 'pointer to int'
(char *)&num casts the pointer to int, to type 'pointer to char'
*(char *)&num takes that pointer to char, and dereferences it to a plain char
That works because an int is more than one byte. We'll assume 4 bytes for this example. It starts at (for example) address 0x1000, and goes through 0x1003. When you set that int to 1, you set the least significant bit to 1, which (depending on the endianness) will be either in the byte at 0x1000 (little endian) or 0x1003 (big endian). So:
Code:
// big endian
0x1000 0000 0000
0x1001 0000 0000
0x1002 0000 0000
0x1003 0000 0001
// little endian
0x1000 0000 0001
0x1001 0000 0000
0x1002 0000 0000
0x1003 0000 0000
Now, the address of num will always be it's "starting" address, i.e. the lowest address, or 0x1000. Cast that to a char, and you still get address 0x1000. But when you dereference it, you only get one byte, the byte at 0x1000 (not the rest of them), because a char is one byte. Thus, if that one byte at 0x1000 is a 1, it's little endian, if not it's big endian*.
* There are also mixed/middle endian architectures out there, but they're not so common any more. Also, some architectures, like ARM, can be configured for big or little endian.