C Programming - Memory Allocation - Discussion
Discussion Forum : Memory Allocation - General Questions (Q.No. 1)
1.
Which header file should be included to use functions like malloc() and calloc()?
Discussion:
37 comments Page 1 of 4.
Harsh said:
5 years ago
Basically, stdlib.h is a standard C header that includes malloc and calloc and free as well.
Vicky Karn said:
6 years ago
malloc(), calloc(), realloc() n free(), all are defined in stdlib.h as well as alloc.h
We can include anyone.
Regarding option, stdlib.h is the answer.
We can include anyone.
Regarding option, stdlib.h is the answer.
Suresh said:
6 years ago
What is the stdib header file can you explain this?
Mohan rsm said:
6 years ago
The malloc() and calloc() are two library fuctions to allocate memory in language c. To allocate a block of memory, call malloc & calloc. The prototype for this function is in 'stdlib.h'.
Vishalakshi said:
6 years ago
I think malloc is better than calloc. Because calloc initialize all its elements to be zero, when memory is allocated. so when you want to insert '0' value in that memory location ,if you want to count the how many times '0' is repeated ,it counts all initialized value and inserted value. so it gives unexpected result.
So malloc is better.
So malloc is better.
Ashwini said:
7 years ago
Hi, friends.
What is brk & sys_brk? Please explain briefly.
What is brk & sys_brk? Please explain briefly.
Saddam said:
7 years ago
According to me malloc() and calloc() is dynamic memory allocation.
Girija sankar said:
7 years ago
I think it should be alloc.h. But it is not in the options. We can prefer standard library i.e (stdlib.h).
Arathy s v said:
8 years ago
How malloc and calloc stored in heap section?
Gmdn said:
8 years ago
malloc is called from user space. stdlib contains the extern declarations needed for malloc. The definition if malloc is present in stdlib (may be glib) which intern calls "brk".
This is system call which in calls sys_brk. This extends the heap memory by specified memory size.
This is system call which in calls sys_brk. This extends the heap memory by specified memory size.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers