Answer the question
In order to leave comments, you need to log in
Why can't an array name be "assigned" a new value?
For example, there is such a declaration and initialization of an array:
It turns out that it points to the first element of a character array. it's just a pointer. Why can't its value be changed so that it points to a new address?
And why can't you create arrays (non-character) in the style of pointers?char arr[] = "string";
arr
arr == &arr[0]
arr
int arr[] = {1, 2, 3, 4, 5}; // ok
int * arr = {1, 2, 3, 4, 5}; // ne ok
Answer the question
In order to leave comments, you need to log in
arr
it's just a pointer.
void f(int arr[])
{
arr = arr + 1;
}
int * arr = (int []){1, 2, 3, 4, 5}; // ok
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question