Do you know the difference between malloc() and calloc() function?
Submitted by: AdministratorThe following are the differences between malloc() and calloc():
- Byte of memory is allocated by malloc(), whereas block of memory is allocated by calloc().
- malloc() takes a single argument, the size of memory, where as calloc takes two parameters, the number of variables to allocate memory and size of bytes of a single variable
- Memory initialization is not performed by malloc() , whereas memory is initialized by calloc().
- malloc(s) returns a pointer with enough storage with s bytes, where as calloc(n,s) returns a pointer with enough contiguous storage each with s bytes.
Submitted by: Administrator
- Byte of memory is allocated by malloc(), whereas block of memory is allocated by calloc().
- malloc() takes a single argument, the size of memory, where as calloc takes two parameters, the number of variables to allocate memory and size of bytes of a single variable
- Memory initialization is not performed by malloc() , whereas memory is initialized by calloc().
- malloc(s) returns a pointer with enough storage with s bytes, where as calloc(n,s) returns a pointer with enough contiguous storage each with s bytes.
Submitted by: Administrator
Read Online C Pointers Job Interview Questions And Answers
Top C Pointers Questions
☺ | What would be the equivalent pointer expression for referring the array element a[i][j][k][l] |
☺ | Tell me with an example the self-referential structure? |
☺ | Explain what is the purpose of "extern" keyword in a function declaration? |
☺ | What is the difference between exit() and _exit() function? |
☺ | Do you know the use of fflush() function? |
Top C Programming Categories
☺ | C Functions Interview Questions. |
☺ | C Pointers Interview Questions. |
☺ | C Preprocessor Interview Questions. |