difference between malloc and calloc

Answer Posted / bijaya

1)malloc() function does not initialize the memory which it
allocates thats why it takes the garbage value.but calloc()
function initializes the allocated memory to zero thats why
it cant take any garbage value.

2)malloc() function takes single arg.that is the variabe
which is used to indicate the memory size to be
allocated.calloc() function takes two args-i) variable which
indicates the number of memory blocks.ii)variable which
indicates the size of each blocks.

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does calloc stand for?

840


What is pivot in c?

747


Explain what are the standard predefined macros?

854


How can I get random integers in a certain range?

779


while initialization of array why we use a[][2] why not a[2][]...?

2079


In C language, a variable name cannot contain?

996


Explain the difference between the local variable and global variable in c?

820


What is the size of enum in bytes?

781


Can we replace the struct function in tree syntax with a union?

998


What is volatile variable in c with example?

773


What is include directive in c?

829


Why can't I perform arithmetic on a void* pointer?

817


Why should I use standard library functions instead of writing my own?

949


Which header file should you include if you are to develop a function which can accept variable number of arguments?

1035


Is it possible to initialize a variable at the time it was declared?

980