Govt. Exams
Entrance Exams
free() is used to deallocate memory that was previously allocated using malloc(), calloc(), or realloc().
stdlib.h contains declarations for malloc(), calloc(), realloc(), and free() functions.
calloc(num, size) allocates num * size = 10 * 4 = 40 bytes total.
malloc() returns a generic pointer (void*) which can be cast to any data type pointer.
stdlib.h contains malloc(), calloc(), realloc(), and free() functions for dynamic memory management.
struct Node { int data; int next; };
Both A and B allocate memory correctly; B includes explicit typecasting which is optional in C but good practice.
Dynamic memory allows flexible sizing at runtime, which static arrays cannot provide.
According to C standard, free(NULL) is safe and does nothing.
calloc() takes two parameters (count, size) and initializes memory to 0, while malloc() takes one parameter and leaves memory uninitialized.
All memory allocation and deallocation functions are declared in <stdlib.h>.