Pointer in C is a powerful weapon, it can let us feel that we can manipulate the memory directly (Literally, not that true since the barrier as virtual memory and page table, but we can consider it like this.) And we know that you can use
& to refer a memory address of a variable, and use
* to deference an address to retrieve the inside value. And the relations between pointer and array, you can blahblahblah for a whole day.
But the question may come across, when do we need to use pointers and why? For instance, why
scanf() need a pointer typed parameter while
printf() doesn’t? We can’t just memorize function names. Aha, this may become tricky since it needs some background knowledge on the memory model. But clam down, we are here to solve it. And the memory model you will learn is not only applied to C, it’s universal. Let’s start!