Passing an Array by reference in C

后端 未结 5 486
渐次进展
渐次进展 2020-12-01 09:34

I\'m new to C and I have a doubt.

Since C functions create local copies of it\'s arguments, I\'m wondering why the following code works as expected:



        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 10:16

    The array name is a pointer to the first element in the array. In the first code sample you have passed a pointer to the memory location containing the first array element. In the second code sample you have passed an integer by value so it has nothing to do with the local variable named "integer"

    check that link

    Pass by reference and pass by value

    Pass by Reference / Value in C++

提交回复
热议问题