understand passing parameters by reference with dynamic allocation

前端 未结 5 2014
难免孤独
难免孤独 2021-01-25 16:59

I\'m trying understand how to pass a parameter by reference in C language. So I wrote this code to test the behavior of parameters passing:

#include 

        
5条回答
  •  野的像风
    2021-01-25 17:40

    The answer posted by nos is correct.

    Also note that the first of the two posted programs will actually crash on many systems, when the printf line in main() tries to dereference main's pointer n, which was never set:

       printf("%d.\n", *n);
    

提交回复
热议问题