指针使用R-1-3-9强制
禁止使用整型数 0 表示空指针
使用整型数 0 表示空指针
test.c
1#include <stdlib.h>23void foo(void)4{5 int *p = (int*) malloc(sizeof(int));6 if (p != 0)禁止使用整型数 0 表示空指针 [gjb8114-r-1-3-9]7 {8 *p = 0;9 }10}
使用 NULL 表示空指针
test.c
1#include <stdlib.h>23void foo(void)4{5 int *p = (int*) malloc(sizeof(int));6 if (p != NULL)7 {8 *p = 1;9 }10}