The preceding code does what is shown in the diagram that follows:
- The first line creates an int * pointer variable, i, which starts as a dangling pointer referring to a segment of memory that probably won't be valid for your program to reference.
- In the second step of the diagram, we use a malloc() call to initialize the variable i to point to a segment of memory precisely the size of an int variable, which will be valid for your program to refer to.
- We then initialize the contents of that memory segment to the value 0 using the command *i = 0;. Refer to the following diagram:
Note the difference between the assignment to ...