Although this is question is more a C question than a an algorithm question, it is in fact a very good question. The calloc function works very like malloc, but it initializes all its bits to zero. It has a little more overhead than malloc, because it must write zeros in the memory, but it could be useful. The syntax are a little bit different: void * calloc ( size_t num, size_t size ); void * malloc ( size_t size );
But take a look in another very useful function: realloc http://www.cplusplus.com/reference/clibrary/cstdlib/realloc/ And do not forget to free the memory! Good luck, Tiago On Jul 11, 5:15 am, RIDER <mohit...@gmail.com> wrote: > what is the advantage of using calloc() over malloc() and in which > case i should use that? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.