C Programming - Memory Allocation - Discussion

Discussion Forum : Memory Allocation - General Questions (Q.No. 2)
2.
What function should be used to free the memory allocated by calloc() ?
dealloc();
malloc(variable_name, 0)
free();
memalloc(variable_name, 0)
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
22 comments Page 2 of 3.

Lijina said:   1 decade ago
malloc() and calloc() are used to allocate space in memory but one difference is there allocating methods.

malloc() : malloc(int) only passing one arguments int allocates 2 bytes.

calloc() : calloc(int,5) passing two arguments int allocates 2 bytes, also 5 times 2 bytes will allocates.

Pandiya raja said:   1 decade ago
@Lijina. What is malloc() and calloc() ?

Can you explain with example program ?
(1)

Soundaryakumari .b said:   1 decade ago
free() : Releases the specified block of memory back to the system.

Vinay said:   1 decade ago
Also Calloc() initialize the allocated memory to zero, while malloc() doesn't.
(2)

Suvrajeetlenka said:   1 decade ago
Can anybody explain what is free() and farfree()?
(1)

Tuks bande said:   1 decade ago
Is the following statement a declaration or definition?

extern int i;

A. Declaration B. Definition
C. Function D. Error

Answer & Explanation

Answer: Option A.

Explanation:

Declaring is the way a programmer tells the compiler to expect a particular type, be it a variable, class/struct/union type, a function type (prototype) or a particular object instance. (ie. extern int i).

Declaration never reserves any space for the variable or instance in the program's memory; it simply a "hint" to the compiler that a use of the variable or instance is expected in the program. This hinting is technically called "forward reference".
(1)

Alex said:   1 decade ago
Memory allocated by malloc or calloc : deallocated by free().
Memory allocated by new(in c++) : deallocated by delete().
(2)

Geetha said:   1 decade ago
What is the purpose of malloc?
(2)

N.Gayathridevi said:   1 decade ago
Explain malloc and calloc with example?
(2)

Bindu said:   1 decade ago
Memory allocated by malloc and calloc are deallocated by free in C.
(1)


Post your comments here:

Your comments will be displayed after verification.