Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7445381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:48:26+00:00 2026-05-29T11:48:26+00:00

I know this question may be marked as a duplicate of difference between malloc

  • 0

I know this question may be marked as a duplicate of difference between malloc and calloc but still i would like to ask it.

i know calloc initilizes the memory block,here my question is not focusussing on that part.

my question is

the definition of malloc says it allocates a block of memory of specified size.

and calloc says it allocates multiple block of memory ,each of the same size.

is this allocation of one block of memory and multiple blocks of memory is a real difference between the two?

because i feel we can do the same using malloc which can be done by calloc.

for example :

int *ptr;
ptr=(int *) malloc(100 * (sizeof(int)));

and

int *ptr;
ptr=(int *) calloc(100,sizeof(int));

would end up allocating 100 times the memory required by the int.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:48:27+00:00Added an answer on May 29, 2026 at 11:48 am

    You are correct with your code examples … the actual memory that is being pointed to by ptr is going to be the same size (i.e., and array on the heap of 100 int objects). As others have mentioned though, the call to calloc will actually zero-out that memory, where-as malloc will simply give you a pointer to that memory, and the memory may or may not have all zeroes in it. For instance, if you get memory that had been recycled from another object, then the call to malloc will still have the values from its previous use. Thus if you treat the memory as if it was “clean”, and don’t initialize it with some default values, you’re going to end up with some type of unexpected behavior in your program.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question may be too product specifc but I'd like to know if anyone
Now this may seem like a silly question, but I need to know how
This may be a duplicate question, but really don't know how else to word
This may not be a programming question, but I don't know where to ask
I know this question may well be the silliest question you've heard today, but
I know this may be a noob question, but it's bugging the heck out
I know this may be a dumb question, but my background is more in
I know this is a total newbie question, but the answer may not be
This may be very simple question,But please help me. i wanted to know what
I know that my this question may sound pathetic to you but as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.