Govt. Exams
Entrance Exams
Doubly-linked list nodes require both next and previous pointers to enable bidirectional traversal unlike singly-linked lists.
NULL return from malloc indicates allocation failure; ignoring causes dereferencing NULL which leads to crash.
In queue implementations using linked lists, NULL front pointer indicates queue is empty as there are no nodes to dequeue.
calloc(n, size) allocates n*size bytes and initializes all to 0, while malloc(size) allocates size bytes with garbage values.
malloc allocates exactly sizeof(int) * 10 = 4 * 10 = 40 bytes. sizeof() operator returns size in bytes.
Calling free(NULL) is safe in C and does nothing. This is by design, allowing you to write code like free(ptr) without checking if ptr is NULL first.
When malloc() cannot allocate the requested memory, it returns NULL. The programmer must check for NULL before using the pointer to avoid undefined behavior.
<stdlib.h> is the standard header file containing declarations for malloc(), calloc(), realloc(), and free() functions.
malloc() is the standard C library function for dynamic memory allocation. It takes the number of bytes to allocate as an argument and returns a pointer to the allocated memory.
calloc(5, sizeof(int)) allocates memory for 5 integers and initializes all to zero.