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 <
There's several ways in C++, but none are quite what you seem to be expecting.
//typedef has a very clear intent
typedef char* array;
void f0(const array a) {}
//switch to pointers to sidestep the problem
void f1(char* const a) {}
//references are inherently const
//can't take pointers, but guarantees the size, sometimes nice
//this version obviously doesn't work in C
template
void f2(char (&a)[n]) {}
http://ideone.com/4LvYT