What's the difference between calloc() and malloc()?
Answers were Sorted based on User's Feedback
Answer / guest
calloc() takes two arguments, and initializes the allocated
memory to all-bits-0.
| Is This Answer Correct ? | 9 Yes | 0 No |
Answer / k.thejonath
Malloc allocates a block of memory whereas using calloc we
can allocate array of memory blocks and all locations are
initialized to zeros
| Is This Answer Correct ? | 5 Yes | 3 No |
Answer / valli
the diffence is
1.prototype or no of arguments
calloc takes two arguments
where as malloc takes 1 argument
void *calloc(int ,int);
first argument is no of blocks required
secund argument is no of elementts in each block required
void *malloc(int);
in this total no of bytes reuired are taken as the argument
2.
calloc clears the bytes which are allocated or reserved
where malloc can not guarentee this
sorry for my poor english
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / bhaswati
malloc allocates m bytes means it takes one arguments.but calloc allocate m times n bytes and initialized the memory location to zero.it takes two arguments.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is hash table in c?
Can a variable be both static and volatile in c?
List some of the dynamic data structures in C?
what is pointer
#include<stdio.h> main() { int a[3]; int *I; a[0]=100;a[1]=200;a[2]=300; I=a; Printf(“%d\n”, ++*I); Printf(“%d\n”, *++I); Printf(“%d\n”, (*I)--); Printf(“%d\n”, *I); } what is the o/p a. 101,200,200,199 b. 200,201,201,100 c. 101,200,199,199 d. 200,300
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
what is the difference between NULL & NUL keywords in C?
Write a program for print infinite numbers
What is #include stdlib h?
write a program that uses point of sale system. which are mainly used by retail markets, where the is a database inventory list, a slip should be printed for the customer. manage should be able to access what has been sold and what is left from stock?
program for swapping two strings by using pointers in c language
Reverse the part of the number which is present from position i to j. Print the new number. eg: num=789876 i=2 j=5 778986