What happens if you use a pointer after calling free() on it (without reallocating)?
How much memory in bytes does calloc(10, 4) allocate?
Which scenario best demonstrates a memory leak?
What is the output of this code?
int *p = (int*)calloc(3, sizeof(int));
printf("%d %d %d", p[0], p[1], p[2]);
If realloc() cannot expand memory at the current location, what does it do?
Advertisement
Consider this code:
int *p = malloc(sizeof(int));
int *q = p;
free(p);
q[0] = 5; // What is the result?
In competitive exams, why is dynamic allocation preferred over static arrays for unknown input sizes?
What is the correct way to allocate a dynamic array of struct for 'n' elements?
struct Node { int data; char name[20]; };
What distinguishes a dangling pointer?
For a program handling 10^6 integers dynamically, which allocation is most appropriate?
What is the typical behavior if malloc() is called in a loop without corresponding free() calls?
Which header file must be included to use dynamic memory allocation functions in C?
What does free() function do in C?
What is the primary difference between malloc() and calloc()?
Which of the following correctly allocates memory for an array of 5 integers and initializes to zero?
A competitive programmer allocates a 2D array dynamically. What is the correct approach?
Consider a program that repeatedly allocates memory in a loop but never frees it. What problem occurs?
What happens if you call free() twice on the same pointer?
In a competitive programming scenario, you need to store strings dynamically. What is safe practice?
A program uses realloc() to expand an array from 100 to 200 elements. The old address is p. After realloc():?