Wish I'd known earlier - C Stuff
I wish I'd known earlier just how arrays variables and pointers are not the same in C. Sure pointer values can be accessed by using syntax of arrays (pointer[index]), but I did not have an idea how it was actually different. So here's how:
If you use
sizeof on an array like so,
sizeof(charArray) you will get the size of the array. Which is to say if we pass a string to
sizeof we will get the length of the string.
But if we use
sizeof on a pointer, that stores the address of a string, we will get 4, or 8. i.e. size of a pointer. 4 bytes for a 32 bit PC, 8 bytes for a 64 bit PC.
The second way they are different is that
&array == array but,
&pointer != pointer.
You can make a pointer point to somewhere else in the memory, but you cannot make an array variable point anywhere else in the memory.
And that's how they are different. :)
ref: PG 59 of Head First C