It's not that convenient an untruth seeing as these are probably some of the first things you learn in C, and some of the first gotchas that'll getcha.
Having said that, the article was well written.
Having said that, the article was well written.
The truth is that array names decay to pointers except when the array is an operand to the `sizeof` or `&` operator.
int arr[5];
int *ptr;
// "arr" has a fixed backing storage of sizeof(int) * 5 bytes
// "ptr" may point to anything or be NULL, depending on control flowC assignment isn't that simple. Consider this program:
#include <stdio.h>
struct point { int x; int y; };
int main(void) {
struct point p1 = { 0, 0 };
struct point p2 = p1;
++p2.x;
printf("(%d, %d), (%d, %d)\n", p1.x, p1.y, p2.x, p2.y);
}
It prints "(0, 0), (1, 0)", as most people would expect. C isn't as transparent a layer over assembler as some people like to imagine; it just doesn't have first class arrays.I like to think of it as one small step above assembly languages; it's certainly not a "portable assembly", but it's about as low as a high-level language can possibly be.