what is calloc and malloc?
Answers were Sorted based on User's Feedback
Hi Jhothi16,
how do u say calloc is for reallocation???..
Ans is,
Both are serving for the purpose of dynamic memory
allocation.
But malloc and calloc differs in two ways.
1.After allocating memory using malloc(), the data elements
in the memory will not be initialised. Means, it contains
garbage values.
But calloc() initialise all the data elements to 0.
2.malloc() allocates memory in terms of bytes.it accepts
only one argument, which says no of bytes to be allocated.
But calloc() allocates memory interms of blocks. it is
widely used when there is a need to allocated memory for an
array.
it accepts two arguments, 1st says, no of blocks to be
allocated and next argument says the size of the block.
ex:
calloc(10, sizeof(int))
-> it allocates 40 bytes, if the compiler allocates 4 bytes
for an int variable.
| Is This Answer Correct ? | 17 Yes | 1 No |
Answer / jothi16
calloc means reallocate the memory.malloc used to allocate
the memory
| Is This Answer Correct ? | 6 Yes | 20 No |
How can I use a preprocessorif expression to ?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.
#include<stdio.h> void main() { int a [5]; for (i=0; i<=4; i++) printf(ā%dā ,a[i]); }
what is the program to display your name in any color?
can we store values and addresses in the same array? explain
Can you please explain the difference between syntax vs logical error?
What’s the special use of UNIONS?
How to add two numbers without using semicolon n c????
What are the 4 types of functions?
write a C program, given number is double without using addt ion and multiplication operator?ex:n=6,ans=12,pls send me ans to goviseenu@gmail.com
Explain what is the benefit of using an enum rather than a #define constant?
what is c programing