Answers for "what happens if i acess a freed variable in c"

C
0

what happens if i acess a freed variable in c

#include <cs50.h>
#include <stdio.h>

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);
}
Posted by: Guest on January-11-2021

Code answers related to "what happens if i acess a freed variable in c"

Code answers related to "C"

Browse Popular Code Answers by Language