C

Asked • 04/11/19

Difference between malloc and calloc?

What is the difference between doing: ptr = (char **) malloc (MAXELEMS * sizeof(char *));or: ptr = (char **) calloc (MAXELEMS, sizeof(char*));When is it a good idea to use calloc over malloc or vice versa?

1 Expert Answer

By:

Mulugeta E. answered • 04/12/19

Tutor
New to Wyzant

Over 4 years of tutoring at College level

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.