WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c
file management?

Answer Posted / ananth kumar

malloc
Holds 1 argument data type
allocates memory byte equivalent to data type
not init alloted memory

Calloc
Holds 2 arguments, data type and number of datas (n)
allocates memory block equivalent to n * data type
clears alloted memory with 0

Is This Answer Correct ?    173 Yes 39 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the advantage of an array over individual variables?

746


How many types of sorting are there in c?

618


What is the purpose of sprintf?

625


hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell

1675


What is the benefit of using #define to declare a constant?

610






One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.

2162


What is a built-in function in C?

799


exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above

667


What is a struct c#?

603


can anyone please tell about the nested interrupts?

1678


Can a pointer be null?

568


Array is an lvalue or not?

642


What is a volatile keyword in c?

643


The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.

1637


Explain setjmp()?

661