Question: Is there any particular reason that if the complier knew an int goes into an address, then it cant remember that an int is there when reading?
As I understand,
line 0tells the compiler to allocate 16 bits for whatever value will be placed there upon assignment inline 3.And I understand that one of the reasons for declaring the pointer type at
line 1is to tell the compiler how many bytes to read when dereferencing the pointerpwith*ponline 6.
0: int i;
1: int *p;
2:
3: i = 5;
4: p = &i;
5:
6: printf("%d",*p);
For simplicity, using bit-width of 8 in mem table.
Say i is written at 0x04 and p is written at 0x02.
addr | storedVal
-----------------
0x01 |
0x02 | 00000100
0x03 |
0x04 | 00000000
0x05 | 00000101