char arr[] = "asds"
Here, arr is just a name. It refers to a memory location but is not a pointer. The compiler substitutes the address directly wherever arr is used. It is not a pointer because unlike pointers, it does not have any space allocated to store an address. It is a mere compile time symbol. Hence, at run-time there is nothing on which you can do pointer arithmetic on. If you had to increment something, that something should exist at run-time.
More details:
Basically, the literal "asds" is stored in your executable and the compiler knows where exactly it is (well, the compiler is placing it in the executable, so it should know?).
The identifier arr is just a name to that location. As in, arr is not a pointer, i.e: it does not exist in memory storing an address.
void func(char arr[])
In case of a function argument, the arr does exist in memory at run-time because the arguments are pushed onto the call stack before making the function call. Since arrays are passed by reference, the address of the first element of the actual parameter is pushed onto the call stack.
Therefore, arr is allocated some space on the stack where it stores the address to the first element of your actual array.
Now you have a pointer. Hence you can increment (or do any pointer arithmetic on it).
sis not an array name instrlens, it's a pointer. Arrays and pointers are distinct types.char s[], thesis a name (compile time symbol; has no run-time significance). It is not allocated any space and hence does not store an address. If you want to do pointer arithmetic, you need to store the address somewhere, don't you? In case of the function argument, the address of your original character array was pushed onto the stack and your function parametersrefers to that. Therefore, the function parametershas space allocated for it where it stores the address. You can now do pointer arithmetic as there is something to which you can do arithmetic on.sis a lvalue inmain. It is not a modifiable lvalue though.int strlens(char s[]);is 100% equivalent toint strlens(char * s);It is interchangeable and the compiler ought to create the exact some code for both.