simple Pointer initialization

前端 未结 7 1774
傲寒
傲寒 2020-12-13 07:14

It has been a while that I used pointers and I just wanna quickly check how I can initialize an integer pointer?

a) int *tmpPtr = 0;

b) int *tmpPtr = null;
         


        
7条回答
  •  星月不相逢
    2020-12-13 07:58

    There is no null keyword in C (at least in ANSI C99). You could use a) or c).

    In c) you'll not initialize pointer with null, you'll initialize it with address of local variable.

提交回复
热议问题