You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This paragraph is not clear, even though it covers an important distinction:
"In most cases, just calling an array by its variable name without the square brackets will be interpreted as a pointer to the first element of the array. Incrementing a pointer will always move it ahead by the number of bytes making up the type to which it's pointing. In other words, incrementing a pointer makes the pointer move by the size of the type. In this case we're dealing with a pointer to an int, so the pointer will move by 4 bytes to the next int. Unlike a pointer, though, an array is a constant variable (see the code snippet above for how that affects p++ and a++)."
I'll try to find time for fixing this but if anyone else has time, please see if you can word it in a less confusing way!
The text was updated successfully, but these errors were encountered:
So I still get email notifs for this so I thought I might add.
I always thought this (perhaps to be reworded for inclusion in recitation notes) excerpt from the C standard was helpful in making the distinction between pointers and arrays:
Except when it is the operand of the sizeof
operator or the unary & operator, or is a character
string literal used to initialize an array of
character type [...] an lvalue that has type “array
of type ” is converted to an expression that
has type “pointer to type ” that points to the
initial member of the array object and is not an
lvalue
Basically just saying that arrays are almost always converted to pointers, yet making it clear that "array of type" is distinct from "pointer to type".
This paragraph is not clear, even though it covers an important distinction:
"In most cases, just calling an array by its variable name without the square brackets will be interpreted as a pointer to the first element of the array. Incrementing a pointer will always move it ahead by the number of bytes making up the type to which it's pointing. In other words, incrementing a pointer makes the pointer move by the size of the type. In this case we're dealing with a pointer to an int, so the pointer will move by 4 bytes to the next int. Unlike a pointer, though, an array is a constant variable (see the code snippet above for how that affects p++ and a++)."
I'll try to find time for fixing this but if anyone else has time, please see if you can word it in a less confusing way!
The text was updated successfully, but these errors were encountered: