ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
   
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c
file management?
 Question Submitted By :: William_vijay
I also faced this Question!!     Rank Answer Posted By  
 
  Re: WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
Answer
# 1
malloc() allocates 1 unit(datatype) of memory each time it
is called so to allocate memory for a file read char by
char allocating memory each time for a char till EOF.
calloc allocates sizeof(datatype) bytes to the no of
elements in the file, where by the user can specify the
file size as the second arguement.
char *malloc(sizeof(datatype) )
char *calloc(sizeof(datatype), num of elements)
calloc() is more efficient as memory is allocated in 1
cycle so fewer clock cycles, more faster executiop.
 
Is This Answer Correct ?    251 Yes 62 No
Chris_sreekanth
[Sankalp]
 
  Re: WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
Answer
# 2
malloc
Holds 1 argument data type
allocates memory byte equivalent to data type
not init alloted memory

Calloc
Holds 2 arguments, data type and number of datas (n)
allocates memory block equivalent to n * data type
clears alloted memory with 0
 
Is This Answer Correct ?    167 Yes 37 No
Ananth Kumar
 
 
 
  Re: WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
Answer
# 3
malloc will only allocate space in the memory..

calloc will allocate space in the memory as well as
initialise it to a particular value.
 
Is This Answer Correct ?    126 Yes 38 No
Shruti
 
  Re: WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
Answer
# 4
malloc () for allocating the single block of memory
calloc () for allocating multiple blocks of memory
the values assigned are garbage in case of malloc() and
proper values (zeros) are assigned in case of calloc().
 
Is This Answer Correct ?    105 Yes 34 No
Prakashdasari
 
  Re: WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
Answer
# 5
1- malloc() takes one argument while calloc takes 2 argument.
2- default value of malloc is garvage while calloc is 0;
3- malloc allocate memory in contiguous form while calloc
allocate memory in contiguous form if not avilable the takes
diffrent place.
 
Is This Answer Correct ?    84 Yes 18 No
Abhishek Pathak Mnnit
 
  Re: WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
Answer
# 6
All the above are true 
Is This Answer Correct ?    56 Yes 33 No
Ragu
 
  Re: WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
Answer
# 7
malloc()
allocates byte of memory and calloc() allocates block of
memory.
 
Is This Answer Correct ?    47 Yes 22 No
Vini Sharma
 
  Re: WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
Answer
# 8
1.
calloc function takes two argument while malloc takes only 1
2.
by default memory allocated by malloc contains garbage values
whereas that allocated by calloc contains all zero.
 
Is This Answer Correct ?    46 Yes 15 No
Arshad
 
  Re: WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
Answer
# 9
malloc occupies byte of space in memory location and holds
only one argument of data bytes.
calloc occupies and holds 2 bytes of memory in address
location with arguments databytes,number of data bytes.
calloc occupies in structure of blocks and malloc allocates
in struncture of databytes.
 
Is This Answer Correct ?    13 Yes 12 No
Venkateswarlupanidapu
 
  Re: WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?
Answer
# 10
malloc() is a one argument function while calloc() is two
argument function
malloc() take garbage value at initial time while calloc()
take null values at initial time
 
Is This Answer Correct ?    26 Yes 12 No
Madan Gopal Singh
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Can we write a program without main() function?  9
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?  1
what are the general concepts of c and c++  2
wat s the meaning of (int *)p +4;  2
what is c language.  3
long int size a) 4 bytes b) 2 bytes c) compiler dependent d) 8 bytes HCL18
write a c program to print the values in words eg:- 143 written it has (one hundred and forty three)& 104, 114 are also written words Captronic5
WHAT IS THE DIFFERANCE BITWIN GETS();AND SCANF(); TCS2
Total of how many functions are available in c?  3
What is sparse file?  1
write a c prog for removing duplicate character from an array and sorting remaining elements using a single array  1
how do we remove the printed character in printf statement and write next it it  1
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2012  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com