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() ?
Discussion:
22 comments Page 1 of 3.
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".
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)
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.
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.
Krishna 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.
Alex said:
1 decade ago
Memory allocated by malloc or calloc : deallocated by free().
Memory allocated by new(in c++) : deallocated by delete().
Memory allocated by new(in c++) : deallocated by delete().
(2)
Vamshikrishna adepu said:
1 decade ago
We doesn't functions like dealloc() in "C" and the remaining options are to allocate memory so may the answer is free().
Anil kumar said:
1 decade ago
free() is one of the predefined function its free memory ...
only one function is there in c language to free memory....
only one function is there in c language to free memory....
Rahul said:
1 decade ago
There are only 3 memory allocation functions in C calloc(),malloc() and free(). free is to free that allocated space
Anonmyous said:
10 years ago
@N. Gayathridevi.
In c++ editor goto help and look for alloc.h.
In that header file examples are given.
In c++ editor goto help and look for alloc.h.
In that header file examples are given.
(2)
MalliReddy said:
10 years ago
In C editor goto alloc.h you will find answer to this question and other memory management func:'s.
(2)
Pokar sanjay said:
1 decade ago
How is different between malloc() and calloc() what is function of both? How it work?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers