I wrote this small piece of code, after executing the code I had this output:
Inside the function: 2
Outside the function: 2
This is not what I expected. I would like to have my "test" array untouched by the function div2. I expected the fucniton div2 just copying the array "test" to "test2" without changing its content.
When you pass array to a function as a parameter what you're really passing is a pointer to the first element of a original array. You can make a copy of array in that function and work with a copy if you don't want to change original array. http://c-faq.com/aryptr/aryptrparam.html