 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can use the log function which is available in dynamic memory location in C programming. Before starting, you can note my information. You can connect with me by following these details where my YouTube channel URL and programming app name Techimages is available. You can open my YouTube channel by searching it through YouTube search bar by typing my name Sanjay Gupta. So my channel will be available there. You can open it. Here various programming related playlists are available. You can improve your programming skills by watching these videos which are available in playlists. You can click on the subscribe button if you want to follow my YouTube channel. Now I am going to demonstrate you the use of real log. So first I have to include header file stdli.h Then another header file that is stdli.h Now I am going to define main function. Here I am declaring pointer p variable n i and variable new size then printf slash n enter size. So before real log function call, I have to call malloc. So real log is called after memory allocation through malloc or calloc. So to allocate memory through malloc or calloc, I am reading this size from user. So for that purpose I am writing scanf. So scanf will read the size in n variable. Now I have received the initial size. So I can allocate memory with the help of this malloc statement. After this memory allocation, if I want to print the elements which are available in that memory block, so I can use this printf statement. Elements are and malloc automatically fills each block with garbage value. So this will print all the garbage values available at different locations. So through this loop I can print each location on console. With this I can print elements on console and at last I am writing return 0. So this way I have allocated memory through malloc and I have displayed all the elements on console. First I am executing this. I am entering size as 6. You can see it is showing garbage values on console. Some are 0 and some are unexpected values. Now after memory allocation, if I want to resize the memory which is allocated through malloc. So I can use printf and I can pass the message enter new size. So I can read that new size again through scanf and this time I am using variable new size. Now I have to call realloc function and here I am passing p pointer and new size variable. So this time realloc will be allocating memory blocks as per this new size variables value and base address will be assigned into p. And this p means the old memory block which is pointed through p. So that memory block will be destroyed and new memory block will be created whose address will be assigned into p pointer. Now to print those elements I can use these statements. So this way I have implemented the code in front of you. So here you can see these statements are for malloc. After malloc I am again reading new size and through realloc I am reallocating memory block and I am printing those memory blocks values on console through this loop. So here n will be replaced with new size. Now I am executing this code. So first size will be 6. So it is printing 6 elements. Now it is asking for new size. So I am entering 10. You can see here 10 elements are displayed now 1 2 3 4 5 6 7 8 9 10. So 10 elements are available here. So after malloc or caloc if you want to increase or decrease that size you can call realloc function. So this is with the help of malloc. Now I am applying caloc. So this change I have to do while using caloc because caloc receive two arguments and it automatically fills each block with 0 and rest of the code will remain same. Now again I am executing this code. I am entering 6. You can see all zeros are displayed here. Now I have to enter new size. So I have entered 10. Now you can see 10 elements are displayed here. So 6 zeros and 4 garbage values. So realloc also fills garbage values. So here I have demonstrated you how you can use realloc function to resize the memory block which is allocated through caloc or malloc. So I hope you have understood how I have implemented this code in front of you. If you want to watch more programming related videos you can follow or subscribe my YouTube channel through the URL youtube.com. You can download my programming app Techimage which is available on Google Play. Thank you for watching this video.