In this statement, you get number, use it as address in memory, which is most likely invalid.
If you want to write
num in binary representation, you should get its address first:
Note the ampersand which is unary operator for getting addresses. I have also used
reinterpret_cast which is C++ type conversion for such cases. C-style conversion may hide errors (but
reinterpret_cast is also valid for
void main() is an invalid prototype of main. It should return
int at least.