What is the difference between malloc() and calloc()?

Author Topic: What is the difference between malloc() and calloc()?  (Read 573 times)

Offline chinmay.sahooTopic starter

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 158
  • Karma: 0
    • Hot Shaper
The two functions mainly is to allocate memory and they are commonly called as memory managers.
     Malloc()  :- Malloc function take one argument
     Calloc()  :- Calloc function take two argument in a time. The bits in the allocated space are initialized to zero.


Offline TomClarke

  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You 50
  • Posts: 874
  • Karma: 0
  • Gender: Male
    • Custom Writing Service & Content Marketplace
Re: What is the difference between malloc() and calloc()?
« Reply #1 on: 04-19-2016, 05:42:01 »
Both malloc ans calloc are used in C language for dynamic memory allocation they obtain blocks of memory dynamically.
But there are two main differences between malloc and calloc in C programming language;
- the number of arguments. The malloc takes a single argument and calloc takes two.
- malloc does not initialize the memory allocated and calloc initializes the allocated memory to 0.
Your ideas, our writings - Writology.com

 

Related Topics

  Subject / Started by Replies Last post
6 Replies
2961 Views
Last post 10-24-2011, 00:30:13
by Hogward
21 Replies
11619 Views
Last post 12-04-2016, 23:34:48
by annarichart
34 Replies
18843 Views
Last post 03-25-2014, 06:13:10
by parijatziw
4 Replies
1885 Views
Last post 11-28-2012, 00:13:19
by DavisJoseph
5 Replies
5863 Views
Last post 04-19-2016, 00:25:36
by TomClarke