a is a constant (array name), you cannot change its value by doing ++a equal to a = a + 1 .
You might want to do *a = *a + 1 (increment 0 with an indexed value), try *a++ instead. Notice that I changed ++ from prefix to postfix.
Note: char* argv[] is defined as a function parameter, and argv is a pointer variable of type char** ( char*[] ).
If your code int* a[] not a function parameter. Here a is an array of type int ( int* ) (array names are constant). Remember the declaration in the function parameter, and normal declarations are different.
Next, using ++ with argv and a , you found only one difference, another interesting difference that you can see if you use the sizeof operator to print the size there. for example check this working codepade code
int main(int argc, char* argv[]){ int* a[2]; printf(" a: %u, argv: %u", sizeof(a), sizeof(argv)); return 1; }
Output:
a: 8, argv: 4
The address size in the system is four bytes. output 8 - the size of the array a consists of two elements of type int addresses (because a is an array), while 4 is the size of argv (because argv is a pointer).
source share