C - Function const Parameters


You can qualify a function parameter using the const keyword.

It indicates that the function will treat the argument that is passed as a constant.

Because arguments are passed by value, using const is only useful when the parameter is a pointer.

Here's an example of a function with a const parameter:

bool test(const char* pmessage)
  return true;

The type of the parameter, pmessage, is a pointer to a const char.

It's the char value that's const, not its address.

The following code uses functional approach to string sorting.

Related Topics