 Hello friends, I am Sanjay Gupta. In this video I am going to discuss with you the predefined functions available for dynamic memory allocation in C programming. Before starting, you can note my information. You can connect with me by following these details which are available in front of you, which contains URL for my YouTube channel and name of my Android app that is Techimage. You can also search my YouTube channel by typing my name in YouTube search bar that is Sanjay Gupta. You can open my channel by clicking on it. Here various programming related playlists are available. You can improve your programming skills by watching these videos which are available in my channel. You can follow my YouTube channel by subscribing it by clicking on this red button which is available in front of you. Now I am going to discuss the predefined functions available for dynamic memory location in C programming. So first you have to know the name of header file which contains declarations of functions of dynamic memory location. So the name is stdlib.h. This header file contains declarations of predefined functions which are responsible for dynamic memory allocation. So first function name is malloc. So malloc is a predefined function. It allocates dynamic memory at runtime. It automatically initializes each block of memory with garbage value. So this is the description of malloc. Now I have to explain you the syntax of malloc so that you can use it. So its syntax is ptr equals to then type pointer then malloc and multiplied by size of data type. So this is the syntax which you can use for dynamic memory location and if the syntax belongs to malloc. So type pointer is the return type of this malloc and this type pointer indicates void pointer. It means malloc can return a pointer or you can say an address after allocating required number of memory blocks. So that required number of memory blocks will be identified with the help of this argument that is n into size of data type. So n is number of arguments which sorry number of blocks which I want to create or user want to create. Then size of data type means size of a particular block which is decided by the data type which is available inside size of operator. So this memory will be allocated malloc will throw an address that you have to convert into a particular type. So here you have to specify a specific type of pointer because by default it contains void pointer and this ptr will be of that specific type. So ptr is a pointer. So the type pointer is suppose integer type then ptr must be of integer type. So now I am going to show you an example how you can use malloc. So this is a simple example of malloc. Here n is multiplied with size of n. So what will be the size of n? It will be 2 bytes for 16 bit compiler and it will be 4 bytes for 32 bit compilers. So that 2 or 4 will be multiplied with n and the allocated memory blocks base address will be thrown and that will be stored inside p pointer. But first it will be typecasted into integer pointer. So p will be of integer type a pointer and n will be of integer type variable which will be containing size of memory entered by the user. So this is the example of malloc. Now second function which is provided for dynamic memory location is caloc. So it is also predefined. It allocates dynamic memory at runtime. It automatically initializes each block of memory with zero value. So this is the description of malloc. Now I can copy these syntaxes and examples. So if I change malloc to caloc then you can write it like this. Here you have to pass 2 arguments. First will be number of blocks and then size of each block. So this is a syntax for caloc. Then now an example I can apply these changes. So this is the example of caloc. So here you have to pass 2 arguments but in case of malloc there is only single argument. So this way you can use caloc and caloc automatically initializes each block with zero value. Now third function which is available for dynamic memory location is free. So free is used to deallocate dynamically allocated memory. So free is a predefined function which is used to deallocate dynamically allocated memory. And how you can use it? You can pass a pointer inside it. So this is the example or you can say syntax of free function. You have to pass a pointer which is pointing to a particular address allocated through malloc or caloc. And you can call free function after completion of each processes. Now fourth function is realloc. So realloc is also a predefined function. It reallocates dynamic memory which is allocated by malloc or caloc. So it is used to reallocate dynamic memory which is allocated through caloc or malloc functions. So after allocation of memory through caloc or malloc if you want to resize that memory block then you can call realloc function. And its syntax is this PTR equals to realloc PTR equals to sorry PTR equals to realloc in parenthesis you can pass PTR comma new size. So this way you can use realloc function in your program to resize the memory which is allocated through caloc or malloc. So these are four predefined functions which are available in dynamic memory allocation in C programming. All these functions are declared in stdlib.h. So whenever you will be using these functions you have to include this header file. So I hope you have understood how you can use malloc caloc free and realloc functions in C programming. So I just have discussed with you the descriptions of these functions and syntaxes and examples. If you want to know how you can develop programs based on dynamic memory location in C programming then you can search a playlist which is available in my YouTube channel named as dynamic memory location. Where all programs based on dynamic memory allocation in C is available. I hope you have understood the concept well. If you want to watch more programming related videos you can follow or subscribe my YouTube channel through the url youtube.com slash sanjay gupta underscore tech school. You can download my programming app Techimage which is available on Google Play. Thank you for watching this video.