What function should be used to free the memory allocated by calloc() ?
Answer: C
free(); function should be used to free the memory allocated by calloc().
Enter details here
Can I increase the size of dynamically allocated array?
Answer: A
Use realloc(variable_name, value);
Enter details here
Consider the following program, where are i, j and k are stored in memory?
int i;
int main()
{
int j;
int *k = (int *) malloc (sizeof(int));
}
Answer: C
No answer description available for this question.
Enter details here
Among 4 header files, which should be included to use the memory allocation functions like malloc(), calloc(), realloc() and free()?
Answer: B
#include
Enter details here
Local variables are stored in an area called ___________
Answer: D
Local variables are stored in an area called stack. Global variables, static variables and program instructions are stored in the permanent storage area. The memory space between these two regions is known a heap.
Enter details here
Can I increase the size of dynamically allocated array?
Answer: A
Use realloc(variable_name, value);
Enter details here
When we dynamically allocate memory is there any way to free memory during run time?
Answer: A
Using free()
Enter details here
What is the Error of this program?
#include
#include
int main()
{
char *ptr;
*ptr = (char)malloc(30);
strcpy(ptr, "RAM");
printf("%s", ptr);
free(ptr);
return 0;
}
Answer: B
None
Enter details here
How many bytes of memory will the following code reserve?
#include
#include
int main()
{
int *p;
p = (int *)malloc(256 * 256);
if(p == NULL)
printf("Allocation failed");
return 0;
}
Answer: B
Hence 256*256 = 65536 is passed to malloc() function which can allocate upto 65535. So the memory allocation will be failed in 16 bit platform (Turbo C in DOS).
If you compile the same program in 32 bit platform like Linux (GCC Compiler) it may allocate the required memory
Enter details here