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 |
what is the c.
What is the difference between abs() and fabs() functions?
Write a C program to find the smallest of three integers, without using any of the comparision operators.
If you know then define #pragma?
Write a C program to perform some of the operation which can be performed using Single linked list
explain what is fifo?
What are the standard predefined macros?
how to calculate the time complexity of a given algorithm? pls give exaples..mainly for the coplexities such as O(log n),O(n log n)...
write a programming in c language, 1 3 5 7 9 11
What is a node in c?
which one of follwoing will read a character from keyboard and store in c a)c=getc() b)c=getchar() c)c=getchar(stdin) d)getc(&c) e)none
find largest of 3 no