C - Dynamic Memory Allocation in C



C Pointers - Definition and Usage

  • In C- Programming pointer is a variable, that is used for storing the address of the variable.
  • In C-Programming Pointer is used for allocating the memory dynamically i.e. at run time.
C Pointers

C Dynamic Memory Allocation - Definition and Usage

  • In C- Programming the memory will be allocated at runtime called as dynamic memory allocation.
  • Generally, the malloc, calloc and realloc are the three functions used to manipulate memory in C-Programming..
C Dynamic Malloc Function

C Dynamic malloc() Function - Definition and Usage

  • In C- Programming the malloc () function is used to allocate space in memory during the execution/runtime of the program.
  • malloc () does not initialize the memory allocated during execution,It carries garbage value.
  • malloc () function returns null pointer if it couldn’t able to allocate requested amount of memory.
C Dynamic Malloc Function

C - calloc() Function - Definition and Usage

  • Calloc () function is similar to malloc function.
  • But in Calloc function the memory space will be initialized before the memory allocation is set as zero.

C - realloc() & free() Function - Definition and Usage

  • In C- Programming the realloc () function is used for modifying the allocated memory size by malloc () and calloc () functions to new size.
  • In C-Programming the realloc function is used for extending the allocate memory space.
C Realloc & Free Function

C Structure - Definition and Usage

  • In C- Programming the Structure is defined as a collection of different data types which are grouped together and each element in a C structure is called member.
  • In C-Programming Structure is similar to array but we can declare different data type in a single structure
C Structure

C Union - Definition and Usage

  • Union and structure in C - Programming are same in concepts, except allocating memory for their members.
  • Structure allocates storage space for all its members separately.
  • Whereas, Union allocates one common storage space for all its members.
  • We can access only one member of union at a time.
  • We can’t access all member values at the same time in union.
  • But, structure can access all member values at the same time.
  • This is because, Union allocates one common storage space for all its members. Whereas Structure allocates storage space for all its members separately.
C Union

View More Quick Examples


Related Searches to C - Dynamic Memory Allocation in C