C Programming - Memory Allocation - Discussion
Discussion Forum : Memory Allocation - Point Out Correct Statements (Q.No. 2)
2.
Which of the following statement is correct prototype of the malloc() function in c ?
Discussion:
11 comments Page 1 of 2.
Shivani said:
8 years ago
Anyone, Please clarify it to me.
ARUNKANTH said:
9 years ago
Why not option "c" because malloc takes unsigned "SIZE" and gives unsigned "ADDRESS".
Madhu said:
1 decade ago
size_t is the size of memory needed to be allocated. Void is the default return type for malloc.
Once malloc allocates memory, it either returns the pointer of allocated address or returns null if fails.
Generally void returns no return type. Still there is no problem. As automatic type conversions are possible for void type. Thus it can return pointer sometimes.
Once malloc allocates memory, it either returns the pointer of allocated address or returns null if fails.
Generally void returns no return type. Still there is no problem. As automatic type conversions are possible for void type. Thus it can return pointer sometimes.
Thirupal said:
1 decade ago
In the malloc function the size will must and should so in the question type of data is void so there is no memory.
Nitish anand said:
1 decade ago
size_t is denotes the no of memory block which is to be allocated.
Ramy said:
1 decade ago
size_t is a data type the compiler already defined
as
typedef unsigned long int size_t
as
typedef unsigned long int size_t
Mehr Shah,Zozi Shah said:
1 decade ago
size_t is possibly a variable which would have been initialized somewhere in the program.
Akshadha said:
1 decade ago
For malloc() function return type is void by default.
Gopi Krishna said:
1 decade ago
Yah! By defalut for malloc () function return type is void.
Val said:
1 decade ago
But what is "size_t"? Is this allowed?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers