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 <
Yes, in C this is possible since C99:
void foo(char ptr_arg[const]);
is valid syntax and equivalent to
void foo(char *const ptr_arg);
More generally the []
may contain any type qualifier, static
and an integer expression. But
The optional type qualifiers and the keyword
static
shall appear only in a declaration of a function parameter with an array type, and then only in the outermost array type derivation.
that is for the dimension that is equivalent to the pointer declaration.