Memory Allocation

Q1:
Which of the following statement is correct prototype of the malloc() function in c ?

A int* malloc(int);

B char* malloc(char);

C unsigned int* malloc(unsigned int);

D void* malloc(size_t);

ANS:A - int* malloc(int);

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.  



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.