WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c
file management?
Answer Posted / smitha
Malloc:
1. Takes only 1 argument- the size of the memory block to
be allocated.
2. Allocates memory as a single contiguous block.
3. Will fail if a single contiguous memory block of
required size is not available.
Calloc:
1. Takes two arguments - the number of memory blocks needed
and the size of each memory block.
2. It may or may not allocate a single contiguous block,
thus will not fail if a single contiguous memory block
of required size is not available.
3. Initialises the memory blocks to 0.
Is This Answer Correct ? | 17 Yes | 3 No |
Post New Answer View All Answers
Is c call by value?
Explain how do you list a file’s date and time?
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
What is the size of a union variable?
Is fortran still used in 2018?
Create a simple code fragment that will swap the values of two variables num1 and num2.
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
What is the purpose of 'register' keyword in c language?
What is merge sort in c?
What are the advantages of c preprocessor?
Why cant I open a file by its explicit path?
What are variables c?
What is variable and explain rules to declare variable in c?