malloc and free Functions in C Programming Language Video Tutorial

In this C programming language video tutorial / lecture for beginners video series, you will learn about the malloc() and free() functions used for dynamic memory allocation in detail with example.

you will learn the syntax of malloc function and free functions, what are the parameters required for the malloc and free functions, how malloc function allocates the bytes of memory from the heap,how free function frees the allocated memory.

You will learn how to create the pointer and allocate the memory dynamically for integers,float and character datatype, and also learn how to allocate the memory dynamically depending on the user input to store a string in detail with an example.

Visit http://www.LearningLad.com for more free computer programming video tutorials.

Learn Programming in HINDI at our youtube channel
http://www.youtube.com/user/LearningLadHindi

Catch us on Social Media
http://www.facebook.com/LearningLad
http://www.google.com/+LearningLad
http://www.twitter.com/LearningLadEdu

Comments

Angelo Soriano says:

Hi Anil! I tried it without casting and it worked, do we really need to cast malloc functions? Is it good practice to cast malloc or not?

Samantha Tite Webber says:

Thank you for showing us this in C. Well-explained video.

Hà Chí Hào says:

what does fflush() do ?

Sagar Jaiswal says:

While taking input of string from the user and printing it why did you use gets(p) and puts(p)… You should be using gets(*p) and puts(*p) right?..

Meruem Sama says:

Firstly, thank you for awesome tutorials. There is something that I could not understand. If you help, I will be thankful.

I want 3 bytes from memory and then equal that to an int. Each integer variable was 4 bytes however the memory which I set it as 3 bytes can be an integer. In theory, it must not work, must it?

int *p;
p=(int *)malloc(3);
*p=10;
printf(“%d”,*p);

It works but it must not. Can you explain it?

Rio Gábor says:

You should do them in c++

Biprodip Sanyashi says:

What is the exactly role of fflush(stdin) function in this program?

rukkumani n says:

why are u using pointer here
main()
{
int *p
p=(int *)mallocof(sizeof(int));
y are u using pointer *p here y we cannot use ordinary variable;

Maulin Shah says:

Hello anil sir,

when i do this program i find an error for malloc() and free(). It shows that they should have prototype… so what are the solution for that..

saipravallika polukonda says:

hello ur way of teaching is awesum sir well in this tutorial u said that malloc() returns address of first byte of alloacated memory but u used void there how it gonna returns den?

dev reddy says:

can anyone explain me clearly why is fflush(stdin) is used or any thing is appreciated?

ls p says:

pointer variable can only hold the address .right?
i dont understand ( *p=20;),
please anyone explain

Zigallo Dee says:

Subtitles please, ALWAYS USE SUBTITLES… please ;-( ;-( ;-( ;-(

NoPTic S says:

Anil, i wanted to ask you a question about pointers,
 int *x = 15;
 printf(“%d”,*x);
why does it crash?
and why when i am doing that it doesnt?
 int *x = 15;
 printf(“%d”,x);

what extacly does x represent without the * operator?

aakash singh says:

I can’t understand one thing that (int*)malloc(sizeof (int)); returns address. But we are using (int*) shouldn’t it returns value to p instead of address . Or (int*) has no effect on (int*)malloc(sizeof (int));.
Please some body help i’m really confused.

Pratibha Goenka says:

These videos were of great help…all the concepts are explained in a very crisp and explicit way…thank you..:)

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours