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 |
Is c still relevant?
Where are some collections of useful code fragments and examples?
Write a program to maintain student’s record. Record should not be available to any unauthorized user. There are three (3) categories of users. Each user has its own type. It depends upon user’s type that which kind of operations user can perform. Their types and options are mentioned below: 1. Admin (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record) 2. Super Admin (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record, Delete Single Record) 3. Guest (Search Record [by Reg. No or Name], View All Records) When first time program runs, it asks to create accounts. Each user type has only 1 account (which means that there can be maximum 3 accounts). In account creation, following options are required: Login Name: <6-10 alphabets long, should be unique> Password: <6-10 alphabets long, should not display characters when user type> Confirm Password: <must match with the Password, should not display characters when user type> Account Type: <One character long, A or S or G where A for Admin, S for Super Admin, G for Guest> Login Name, Password and Account Type should be stored in a separate file in encrypted form. (Encryption means that actual information should be changed and Decryption means that Encrypted information is changed back to the actual information) If any of the above mentioned requirement(s) does not meet then point out mistake and ask user to specify information again. When Program is launched with already created accounts, it will ask for user name and password to authenticate. On successful authentication, give options according to the user’s type.
What is the use of a static variable in c?
main() { char *p; p="Hello"; printf("%c\n",*&*p); }
What is the use of bit field?
what is the function of .h in #include<stdio.h> in c ?
23 Answers HCL, IBM, Wipro,
Diff between for loop and while loop?
what is the c source code for the below output? 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1
How can I find the modification date and time of a file?
Sir i want e-notes of C languge of BAlaguruswami book i.e scanned or pdf file of balaguruswamy book on c language.PLEASE SEND ME on my mail id ajit_kolhe@rediff.com
Do string constants represent numerical values?