Are pointers considered a method of calling by reference in C?

后端 未结 8 1631
暖寄归人
暖寄归人 2021-01-30 10:31

In my University\'s C programming class, the professor and subsequent book written by her uses the term call or pass by reference when referring to poin

8条回答
  •  温柔的废话
    2021-01-30 10:55

    Your professor is right. By value , it is copied. By reference, it is not copied, the reference says where it is.

    By value , you pass an int to a function , it is copied , changes to the copy does not affect the original.

    By reference , pass same int as pointer , it is not copied , you are modifying the original.

    By reference , an array is always by reference , you could have one billion items in your array , it is faster to just say where it is , you are modifying the original.

提交回复
热议问题