Multiple choice technology programming languages

What will happen? int main(int argc, char*argv) { char ptr = NULL; free(ptr); return 0; }

  1. core dump

  2. nothing

  3. undefined behavior

  4. all the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In C, calling free(NULL) is explicitly defined to do nothing. The C standard (C99 7.20.3.2) states that if ptr is a null pointer, no action occurs. It does NOT cause a core dump or undefined behavior. This is different from freeing an already-freed pointer or freeing unallocated memory, which are undefined. Option B is correct - 'nothing' happens.