Difference Similarity Following C Language Mallac Free Pointer Variable Address Q37066949

A difference and Similarity for each of the following (Clanguage):

Mallac() & free()

Pointer variable & Address


Solution


Give adifference and Similarity for following:

(1) Mallac() & free()

Similarity:

malloc() and free() both are manual ordynamic memory management functions. They both are libraryfunctions that defined under C standard library<stdlib.h>.

Difference:

Function malloc() allocatesthe memory where as Function free() de-allocatesthe memory.

malloc():

● Function”malloc” as the name suggests it does dynamic memory allocation.Malloc() function basically allocates or reserves a size byte of amemory.

Syntax: (type *) malloc(sizeof(type));

● This statementreserves or allocates a byte specified block of memory and itreturns void type pointer that

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.