When passing an array as a parameter, this
void arraytest(int a[])
means exactly the same as
void arraytest(int *a)
so you are modifying the values in main.
For historical reasons, arrays are not first class citizens and cannot be passed by value.
More Related Contents:
- Difference between passing array and array pointer into function in C
- Why do we need to specify the column size when passing a 2D array as a parameter?
- Parameter Passing in C – Pointers, Addresses, Aliases
- Manipulate multidimensional array in a function
- Why isn’t the size of an array parameter the same as within main?
- How do I modify a pointer that has been passed into a function in C?
- C sizeof a passed array [duplicate]
- How do you pass a function as a parameter in C?
- Why does a C-Array have a wrong sizeof() value when it’s passed to a function? [duplicate]
- What is the purpose of static keyword in array parameter of function like “char s[static 10]”?
- Allocate memory 2d array in function C
- Pass an array to a function by value
- Pointers as function arguments in C
- Returning Arrays/Pointers from a function
- Why use an asterisk “[*]” instead of an integer for a VLA array parameter of a function?
- Changing array inside function in C
- When is an array name or a function name ‘converted’ into a pointer ? (in C)
- How can I return a character array from a function in C?
- Unspecified number of parameters in C functions – void foo()
- Passing an Array by reference in C
- In a C function declaration, what does “…” as the last parameter do?
- How can I malloc a struct array inside a function? Code works otherwise
- C pointer notation compared to array notation: When passing to function
- Dynamic Array of strings [closed]
- C pointer to array/array of pointers disambiguation
- C Programming: malloc() inside another function
- C – allocating a matrix in a function
- Is it possible to allocate array inside function and return it using reference?
- How to use the rand function to make numbers in a specific range?
- What does *& mean in a function parameter