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

program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

2580


What is mean by data types in c?

557


Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.

707


What are two dimensional arrays alternatively called as?

667


What is p in text message?

544






Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

678


How would you use the functions fseek(), freed(), fwrite() and ftell()?

708


what is different between auto and local static? why should we use local static?

648


Can a variable be both constant and volatile?

564


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3192


What are the different data types in C?

731


What is break in c?

590


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

618


Explain about the constants which help in debugging?

858


Why calloc is better than malloc?

574