Which is better malloc or calloc?



Which is better malloc or calloc?..

Answer / Rahul Thapa

The choice between malloc and calloc depends on your needs. malloc just allocates memory, while calloc initializes the allocated memory to zero. If you need initialized memory, use calloc; otherwise, if speed is more important, use malloc.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Write a c program to find, no of occurance of a given word in a file. The word is case sensitive.

2 Answers  


what is array?

8 Answers  


main() { int i; printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i)); } ans is 24 bt how?pls tell smbody............

3 Answers  


what will be the result of the following program ? char *gxxx() { static char xxx[1024]; return xxx; } main() { char *g="string"; strcpy(gxxx(),g); g = gxxx(); strcpy(g,"oldstring"); printf("The string is : %s",gxxx()); } a) The string is : string b) The string is :Oldstring c) Run time error/Core dump d) Syntax error during compilation e) None of these

2 Answers   IBM,


Where in memory are my variables stored?

1 Answers  


while running a program, i got the msg that press return key to exit.what that mean in C as there are no such options as far i know.

1 Answers   TCS,


program to find middle element of linklist?

1 Answers   Huawei,


what is meant by the "equivalence of pointers and arrays" in C?

3 Answers   Satyam,


When should the volatile modifier be used?

1 Answers  


what is the advantage of software development

1 Answers  


Write a program to compute the following 1!+2!+...n!

4 Answers  


Write a program to generate prime factors of a given integer?

2 Answers  


Categories