retagged by
7,089 views

3 Answers

0 votes
0 votes
dynamic memory allocation
0 votes
0 votes

malloc() and calloc() both are used to dynamically allocate the memory from heap. Option A


​​​​​​​Bonus:-

  • malloc() allocates the memory, but doesn't initialize any values. Hence if you try to immediately access the memory contents of a piece of memory allocated through malloc(), you'll get garbage value.
     
  • calloc() allocates the memory and initializes it to 0. Hence if you try to immediately access the memory contents of a piece of memory allocated through calloc(), you'll get 0.
     
  • malloc() takes a single argument in which you specify the size of the memory block wanted.
     
  • calloc() takes two arguments — first, to specify how many blocks you want; second, to specify what size per block you want.
Answer:

Related questions

8 votes
8 votes
4 answers
2
sh!va asked May 7, 2017
5,460 views
What is the output of the following program?#include<stdio.h int tmp=20; main() { printf("%d", tmp); func(); printf("%d", tmp); } func() { static int tmp=10; printf("%d",...
15 votes
15 votes
1 answer
3
8 votes
8 votes
5 answers
4
sh!va asked May 7, 2017
8,638 views
What will be the output of the following C code?#include <stdio.h main() { int i; for(i=0;i<5;i++) { int i=10; printf("%d" , i); i++; } return 0; }10 11 12 13 1410 10 10 ...