C examples for Function:Function Parameter
To prevent an array argument from being altered in a function, use the const qualifier.
#include <stdio.h> void printArray(const int []); int main() { //from w w w . ja va2 s. c om int iNumbers[3] = {2, 4, 6}; printArray(iNumbers); return 0; } void printArray(const int num[]) //pass by reference, but read-only { int x; printf("\nArray contents are: "); for ( x = 0; x < 3; x++ ) printf("%d ", num[x]); }