I was referring to the book, "C Programming Just the FAQs" by Paul S R Chisholm. According to the author, "Because the array is being passed by value, an exact copy of the array is made and placed on the stack. The called function then receives this copy of the array and can print it. Because the array passed to byval_func() is a copy of the original array, modifying the array within the byval_func() function has no effect on the original array"
But I thought if we pass array as given in his example, it will alter the array even in calling portion. I even tried and it was as per my expectation. Please correct me if I am wrong.
Below is the example given in the text book.
void byval_func(int[]);
void main(void)
{
int x[10];
int y;
/* Set up the integer array. */
for (y=0; y<10; y++)
x[y] = y;
/* Call byval_func(), passing the x array by value. */
byval_func(x);
}
/* The byval_function receives an integer array by value. */
void byval_func(int i[])
{
int y;
/* Print the contents of the integer array. */
for (y=0; y<10; y++)
printf(“%d\n”, i[y]);
}