2 ms·
Geez. No. int i[10]; does allocate memory for 10 integers (on the stack) So i has the type int•. A pointer to a value: an array. A pointer to a value is the s
by gizmo 18y ago
Geez. No.
int i[10]; does allocate memory for 10 integers (on the stack)
So i has the type int•. A pointer to a value: an array. A pointer to a value is the same thing as a pointer to the first value in the array. That's why you can use ++i, increment the pointer, and it will point to the second value in the array (++i => •i == i[1])
So &i is, wait for it, a int••, that is, a pointer to an array. So if you have an array of arrays, then you need to dereference twice. E.g. argv. It's a char••, so an array of strings which is an array of arrays of characters.
- kylec 18y agoIf you declare int i[10]; you can't do ++i because modification of the value of i is not allowed.
- gizmo 18y agoYeah, but that's not the point. It's about which address points to which place. An array always points to its 0th member in C by default - that was the point. Declare int• j = i; and you can do as much pointer shuffling as you want.