📜  如果我在 C 编程语言代码示例中访问释放的变量会发生什么

📅  最后修改于: 2022-03-11 15:04:37.109000             🧑  作者: Mango

代码示例1
#include 
#include 

int main(void)
{
  {
    int* px = malloc(sizeof(int));
    *px = 3;
    printf("&px = %i, px = %p\n", *px, px);


    free(px);

    if( px == NULL)
        printf("px is null after free\n");
    else
        printf(" px = %p\n",px);
   }
//     this printf would demonstrate that px is out of scope.
//            printf(" px = %p\n",px);
}