Is there any way that I can add const keyword to an array passed as a parameter to function:
void foo(char arr_arg[])
If I place const before char (void foo(const char arr_arg[])) or after char(void foo(char const arr_arg[])), that would mean than it's char which is constant, not the arr_arg.
I have just read that under the hood an array sent as a parameter to function is represented as a pointer, so void foo(char arr_arg[]) is the same as void foo(char* ptr_arg).
Taking it into account, I may rewrite the function as void foo(char * const ptr_arg) for it to be exactly what I want to achieve.
But I want to know if there is a way to add const keyword in this declaration void foo(char arr_arg[]) for it to be the same as void foo(char * const ptr_arg) (and not void foo(char const * ptr_arg) or void foo(const char * ptr_arg))?
I just want to understand if there is a syntax to make arr_arg constant with array notation [].
void foo(char * const ptr_arg)? It's exactly the same syntax everywhere else. You can still do ptr_arg[0] as if it was declared as an array.[]. No specific reason. Just want to clarify if it's possible or not (just to know in the future and not waste time contemplating if it's possible or not again and again).