If the alignment requirements of types int and float are not the same, then this program potentially causes undefined behavior.
If the requirements are the same, then
- The value of ptr_i is NOT 1115881472. The value of ptr_i is the address of object f. 1115881472 is the decimal representation of whatever data is in object f when those bits are interpreted as an int.
- The value of ptr_f is NOT 0.000000. The value of ptr_f is the address of object a. 0.000000 is the decimal representation of whatever data is in object a when those bits are interpreted as a float.
- You printed the values in different formats (one int and one promoted to double). Why would you expect the output to be the same?
- You printed different values. Even if you used the same format, the output would be different.
- If you want to know how the system arrived at that particular set of output, you need to research how your system stores int and float data.
You initialized your two primary variables to bit patterns appropriate for their defined types. Why do you think telling printf to interpret those patterns as a different type produces anything meaningful? Did you think that changing the type of the pointer used to access the memory would somehow magically convert the data in memory to match the new pointer?