Pointers and Arrays
Get to learn how C uses pointers to reference arrays.
We'll cover the following...
Arrays under the hood
When we declare an array using an expression like int vec[5];
, what is really happening behind the scenes, is that a block of memory is being allocated (on the stack in this case) large enough to hold five integers, and the vec
variable is a pointer that points to the first element in the array. When we index into the array with an expression like printf("vec[2] = %d\n", vec[2]);
what is really happening is that C is using ...