Linux Startup and Shutdown Question: Download Questions PDF
Program given below will allocate the memory of ___ bytes for pointer "ptr".
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr;
ptr = (int*)malloc(sizeof(int)*4);
ptr = realloc(ptr,sizeof(int)*2);
return 0;
}
a) 2
b) 4
c) 8
d) none of the mentioned
Answer:
c) 8
Explanation:
We can also use the realloc() to make memory block smaller.
Explanation:
We can also use the realloc() to make memory block smaller.
Download Linux Shutdown & Startup Interview Questions And Answers
PDF