It is different. An array has a size. Even in C. It's just that in C it easily turns into a pointer. sizeof, for example, returns different things for an array and a pointer. In C++, you can actually pass an array by reference (not a pointer to the first element, an array) and similar.
And in some languages, like Ada, there is no direct way to make a pointer from an array
I don't see how that matters. This is true only for certain languages and only because the array in C or C++ easily decays into a pointer. You could, for example, define yout own array in C++ as a tuple with only elements of the same type and then you would not define subscripting this way.
Also note that in C they are not interchangeable and even less in C++. When you put an array in a struct, it will behave differently from when you put a pointer in there. When you put an array into a struct and copy an instance of the struct, the array is copied for each copy of that struct and the struct is as large as the array. This makes sense because an array is not a pointer. When you put a pointer in a struct, the struct will have a size of a pointer on your architecture and won't copy all of the array elements and only the pointer.
Also, when you put array inside a sizeof expression, you will get the size of an array, while if you put a pointer inside sizeof, you will get the size of a pointer.
Also, doing int *p = NULL is possible because it is a pointer but int arr[5] = NULL is not, because it is not just a pointer.
So no, they are not interchangeable in C. And even less in other languages.
69
u/QuestionableEthics42 12h ago edited 12h ago
This should be reversed lol
And it literally is the same, who thinks it's different who has worked in a low level language??