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()?
memory.h
stdlib.h
string.h
dos.h
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
37 comments Page 1 of 4.

Janardan said:   1 decade 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'.

Wahid sayed said:   1 decade ago
Then when do we use memory.h ?

Likita shetty said:   1 decade ago
I thought its just "alloc.h" .. i remember my program working by using just alloc.h

Mahesh said:   1 decade ago
The header file will be alloc.h but it is not in the option.

Sundar said:   1 decade ago
We can include any of the following header files

1. stdlib.h
2. alloc.h

Since alloc.h is not provided in any option. Therefore stdlib.h is the correct answer.

Hope this help you. Have a nice day!

Ruthran said:   1 decade ago
stdlib.h header file only have prototype of malloc() and clloc()

Anubhav Singh said:   1 decade ago
we know that stdlib is standard library which include mostly all segments of header files it is like an package, which contains these like alloc.h, malloc.h etc.

Gudevenkatrao said:   1 decade ago
What is the syntax of malloc() ?

Latha said:   1 decade ago
Give difference of malloc & calloc ?

Kunjal said:   1 decade ago
Both allocate storage memory but the difference is malloc process single argument so just specify storage space while calloc process double argument so specify no. Of variable and space needed for that variable.


Post your comments here:

Your comments will be displayed after verification.