C_133 Dynamic Memory Allocation using malloc() | C Language Tutorials

Sdílet
Vložit
  • čas přidán 13. 08. 2024
  • C complete playlist: • Programming in C
    Use my code jkl10 to get 10% off on GATE subscription
    GATE Subscription- unacademy.com/...
    Evolve for GATE 2023 (CS & IT) - Batch unacademy.com/...
    Spark for GATE 2023 (CS & IT) - Batch D (English)- unacademy.com/...
    Ascend for GATE 2024 (CS & IT) - Batch G- unacademy.com/...
    Connect & Contact Me:
    Vlogging Channel Link: bit.ly/354n7C7
    Facebook: / jennys-lectures-csit-n...
    Quora: www.quora.com/...
    Instagram: / jayantikhatrilamba
    Twitter: / khatrijenny
    See Complete Playlists:
    Placement Series: • Placements Series
    Data Structures and Algorithms: https: • Data Structures and Al...
    Design and Analysis of Algorithms(DAA): • Design and Analysis of...
    Dynamic Programming: • Dynamic Programming
    Operating Systems: // • Operating Systems
    DBMS: • DBMS (Database Managem...
    #Cprogrammingtutorials
    #DynamicMemoryAllocationinC
    #mallocfunctioninC
    #Jennyslectures

Komentáře • 248

  • @grow_free
    @grow_free Před rokem +212

    In static memory allocation you have a glass full of water and in dynamic memory allocation you have an empty glass and a jug and you can take as per your need.

  • @user-su6gl9cz6z
    @user-su6gl9cz6z Před 10 měsíci +16

    1. Static Memory Allocation (Toy Shelves):
    Imagine you own a toy store, and you have a fixed set of shelves with five slots. Each slot can hold a different toy. You decide in advance which toys will go into each slot. Once the toys are placed, you cannot change the shelves' structure, and the toys in those slots are fixed. This is similar to static memory allocation.
    2. Dynamic Memory Allocation (Toy Store with Adjustable Shelves):
    Now, imagine you own a toy store, but this time you have the ability to add or remove shelves as needed. You start with an empty store and add shelves to accommodate toys as customers come in. If a customer leaves, you can remove the shelf to free up space. This represents dynamic memory allocation.

  • @suguflick119
    @suguflick119 Před rokem +10

    Ma'am, your ways of explaining concepts are too good, I learnt C and C++ at least 2 decades ago. Wish we had someone like you to teach us, would have aced it for sure.
    Thank you so much for your support.

  • @AnuragRawat01
    @AnuragRawat01 Před rokem +12

    Real life example:-
    Static memory allocation:- having wallet so that we can pay currency notes whenever we need , for that we need to keep as much money inside wallet as expected no matter it'll be used or not.
    Dynamic memory allocation :- rather than having a wallet to pay money, we can keep Google pay or Paytm on our mobile so that we can pay money as per the need there will be no tention to keep currency notes
    Hope u guys can relate with it😅😅

    • @lokesh6828
      @lokesh6828 Před 10 měsíci

      not that appropriate example according to me

    • @AnuragRawat01
      @AnuragRawat01 Před 10 měsíci +1

      @@lokesh6828 sad to know
      My bad😢😢

    • @lokesh6828
      @lokesh6828 Před 10 měsíci

      @@AnuragRawat01 I have modified you example, maybe that is more appropriate

    • @lokesh6828
      @lokesh6828 Před 10 měsíci +2

      @@AnuragRawat01
      The real life example can be
      Static memory allocation : Having Rs 10000 from which you can purchase anything but you cannot resell it.
      dynamic memory allocation: having Rs 100000 from which you can rent anything around you and when to return the rented item, you will get full refund and you can use it again and again.

  • @bhagyashripatil586
    @bhagyashripatil586 Před 2 lety +22

    Mam I love ur lecture due to u I can write program and also understand program

  • @staywithmiseren6754
    @staywithmiseren6754 Před 2 lety +35

    Ma'am I am from northeast! Currently doing my BSC in Cs ! Your videos make programming even more better and easier! ✌️❤️❤️❤️

  • @tiago.c
    @tiago.c Před rokem +6

    I'm watching another C course besides Jenny, both are amazing, but everytime I get confused there I come here and find the information missing that I was asking for in the other course. Anyway, no course is able to cover every aspect of a subject, so they are complementary, and Jenny is always great on explaning, thank you so much!

    • @erinsumner1550
      @erinsumner1550 Před 3 měsíci +1

      Which other one did you watch? (If you don't mind me asking)

    • @tiago.c
      @tiago.c Před 3 měsíci

      @@erinsumner1550 Portpholio Courses

  • @pavanipyna3797
    @pavanipyna3797 Před 2 lety +11

    mam please upload a video on malloc function using structure

  • @charimuvilla8693
    @charimuvilla8693 Před 2 lety +12

    Hi Jenny love your videos! I would be very interested in a video that further explains how this magic box called malloc works behind the scenes. How does it find memory to give you? How expensive is it to call it and what are some good practices? Does memory fragmentation affect it at all?

  • @ambika1.5m78
    @ambika1.5m78 Před 2 lety +23

    Ma'am plz upload the vedio. That how can we use maloc( ) ,in structure 🙏🙏🙏
    It's my heartly request ma'am

  • @pranavrawal9033
    @pranavrawal9033 Před rokem +5

    Perfectly explained everything, an absolute perfection you have in your videos mam.

  • @parisa9374
    @parisa9374 Před 2 lety +20

    May you please give an example of malloc() for structure as you suggested in this video? Thank you very much!

  • @rohank009
    @rohank009 Před 9 měsíci +2

    Madam please provide video lecture on dynamically allocated structure concept
    what ever you are teaching is very useful and informative thanks for the concern.

  • @RamakrishnaPrince
    @RamakrishnaPrince Před 2 lety +5

    reacently watched "c" videos way of teaching excellant lot of knowledge is their in your videos ☺, as early as possible can you start java.thank you mam,yours loving student😘

  • @sanjays7255
    @sanjays7255 Před 2 lety +5

    Extraordinary teaching ma'am 🔥🔥🔥

  • @UdaykumarKUday-yd9ut
    @UdaykumarKUday-yd9ut Před rokem +5

    I didn't understand chapati concept madam, because I don't know hindi. But I understand what you are going to teach.😉😉

  • @jayasuriya9285
    @jayasuriya9285 Před 2 lety +2

    a[n] , where 'n' is the number of integer data that user wanted to add. Now no memory is wasted right??. Is it now static??

  • @vijayjeee8806
    @vijayjeee8806 Před 2 lety +8

    Thank u mam for doing vedios on c it helping a lot i recommend so many students on my college and you make it c as easy😊😊

  • @rahulannarayan
    @rahulannarayan Před 2 lety +4

    I like your dynamic chapati allocation example....can relate to it

  • @johnabednego6728
    @johnabednego6728 Před 2 lety +3

    Whaooo, cannot stop watching your lecture! Thanks very much ☺

  • @merveilleskatumba2886
    @merveilleskatumba2886 Před rokem +2

    Thank you , your videos are amazing ....I am loving C

  • @cosminboglis5160
    @cosminboglis5160 Před rokem +3

    Thank you very much! Such great videos!

  • @bipinkadayat
    @bipinkadayat Před 2 lety +4

    Thank you so much man🙏🤍
    Please Mam make a video
    Display the names in alphabetical order🤍

  • @antoniomike2972
    @antoniomike2972 Před 2 lety +1

    Though your English is a bit hard to listen to, I get familiar with it while turning on the caption. Actually, I'm learning another paid course, but I must watch your lessons because they're very easy to understand, they're helping me to figure out what is really under the hood.

  • @vanajacreations2.741
    @vanajacreations2.741 Před 2 lety +8

    The video will be started at 2:29 you can thank me later

  • @divyanshbalodhi5642
    @divyanshbalodhi5642 Před 2 lety +3

    Very good explanation 👍

  • @zaidumar1174
    @zaidumar1174 Před 2 lety +3

    Hello, mam can you make a video on matrix chain multiplication, regarding dynamic programming please!!
    With regards... From me
    Thank you 😊

  • @Prince_D_Coder
    @Prince_D_Coder Před rokem +1

    Your videos are really helpful

  • @vattianil2159
    @vattianil2159 Před 2 lety +2

    Amazing teaching 👏 mamm

  • @allmix608
    @allmix608 Před 2 lety +1

    Mam u r looking good in this red colour

  • @sanjays7255
    @sanjays7255 Před 2 lety +1

    Mam here I have a doubt,we can also reduce the memory waste using"" variable length array concept ""mam.then why we want to use malloc for reduce memory waste

  • @ajaykumarharijan9734
    @ajaykumarharijan9734 Před 2 lety

    Mam I liked your teaching way as well as your hair style 🥰

  • @jecodedoncjesuis875
    @jecodedoncjesuis875 Před 2 lety +1

    Please Mam, as soon as you speak your language, we lose your explanations.
    Your explanations are so valuable that we don't want to miss a word of what you say.
    Remember that people follow you all over the world; United States, Europe, Africa..

    • @plumSlayer
      @plumSlayer Před rokem

      I'm really sorry for the inconvenience, a temporary soluiion could be, pls mention the time over here and ig someone kind enough could explain the part spoken in Hindi Language....

  • @crazysoul6987
    @crazysoul6987 Před rokem +1

    Amazing Explanation 🍓🌚🙊

  • @bitsforbits6581
    @bitsforbits6581 Před rokem

    even sandeep jain couldnt make me understand dma...but you did it ma'am...

  • @Vincent45678
    @Vincent45678 Před rokem +1

    After free(ptr) when I printing the values the values are being printed, But after free(ptr) the values should not be printed na... Why Is this happening May I know where did I did the mistake...

  • @eutychuskurria7765
    @eutychuskurria7765 Před rokem

    Huge fun and a follower you have a mentor in c language i just get trouble in understanding your language when you shift from English to ..... leaving me hanging . But you are be best

  • @akhilmittal3283
    @akhilmittal3283 Před 2 lety +1

    thanks mam u looking superb mam

  • @ArjunSingh-wr3jk
    @ArjunSingh-wr3jk Před rokem

    If we want to creat a pointer normally then we can write int*ptr=&any variable this things int* ptr=variable

  • @sakinasicora2231
    @sakinasicora2231 Před 2 lety +1

    Just a genuine question, do you take personal tutions of students, I do understand your course, but sometimes I've got program questions which are difficult to understand 😅

  • @indianshort1669
    @indianshort1669 Před 2 lety

    Mam your teaching style is as beautiful as you 🙏🙏🙏

  • @GajulaSaikumar-ju7rl
    @GajulaSaikumar-ju7rl Před rokem

    Why can't we use
    Int n;
    Scanf("%d",&n);
    Int a[n]
    It is also working
    We are giving input at runtime

  • @prereloluwa
    @prereloluwa Před rokem +2

    Thnak you for the explicit exposition
    You are fantastic.
    At 22:18 I had some confusions. I thing you spoke your dialect. 👍

    • @amangupta257
      @amangupta257 Před rokem

      You can Google it brother

    • @amarnathsivalingam754
      @amarnathsivalingam754 Před rokem

      she was explaning the logic of Dynamic memory allocation and its importance of a their food Chappathi.
      if you request your friend to bring you chappathi delivered @ your home since you are not sure how much hunger you are in, your friend might possiblly bring more number of chappathi (for eg:) 5 but you may eat just 2 or 3 and rest is a waste which is a example of Static memory.
      Where as if you go to a canteen or a restraunt and get the food according to your need and there is no wastage which is the example of Dynamic memory.

  • @saidurgaaravindsurisetti8406

    Tq mam for u work for us

  • @haider__khan4567
    @haider__khan4567 Před 2 lety

    I like you, your teaching style.

  • @codemyway69
    @codemyway69 Před 2 lety

    It feels very lovely when i listen uh speaking hindi🥰🥰🥰

  • @user-ud4cu1rn6q
    @user-ud4cu1rn6q Před 2 lety

    Good explanation
    Superrr sis...

  • @abhishek5212
    @abhishek5212 Před 7 měsíci

    Thank you so much lovely ma'am ❤😊

  • @Education..29071
    @Education..29071 Před 2 lety

    You are beauty with brain 😊😊😊😊😍

  • @dr.balaraju.j.7868
    @dr.balaraju.j.7868 Před rokem

    madam great explanation

  • @priya-we2hg
    @priya-we2hg Před 2 lety +1

    Good evening mam🙏🙏🙏💐💞❤

  • @codewithbishal895
    @codewithbishal895 Před 2 lety +1

    god level teaching

  • @aswinkumarraj5054
    @aswinkumarraj5054 Před 2 lety

    I have just entered values with Upto n+5 (in for loop, like i

  • @msvpraveenpallapothu1720
    @msvpraveenpallapothu1720 Před 2 lety +1

    Please reply still how many videos are there to complete c programming language

  • @anuj9615
    @anuj9615 Před 2 lety

    I'm die hard fan of you ❤️
    Love you from NEPAL 😙

  • @indianlegendking9071
    @indianlegendking9071 Před 7 měsíci

    Love from Andhra Pradesh 😊😊

  • @baahbernard4183
    @baahbernard4183 Před rokem

    You are so good ma'am 🤩

  • @sharuk98ala
    @sharuk98ala Před 2 lety

    You are Gorgeous, One of Gods great creations.♥️

  • @sujithsenthilraj6798
    @sujithsenthilraj6798 Před rokem

    In that y we are using int* at first of malloc (time:10:46) y we can't use int alone

  • @depanshusharma3113
    @depanshusharma3113 Před rokem

    Which one is better
    p is pointer and i is in loop
    Scanf(“%d”,&p[i])
    Or
    Scanf(“%d”,(p+i))

    • @ananthu4141
      @ananthu4141 Před 11 měsíci

      I think the 1st one....its more comfortable... Bt is it correct in this case?

  • @CodewithIk1177
    @CodewithIk1177 Před 9 měsíci

    amazing lecture mam

  • @bhaskarnaik5842
    @bhaskarnaik5842 Před 2 lety

    I became fan of your beauty ❣️

  • @dharmabhai5728
    @dharmabhai5728 Před 2 lety +1

    Super timeing edi matram

  • @suchind7558
    @suchind7558 Před 2 lety

    Mam op teaching i like ur lecture

  • @vamsimathi1630
    @vamsimathi1630 Před rokem

    Nice explanation..

  • @motivationalblogrameshpaul3005

    Love teaching 🎈❤️

  • @TekSandeep
    @TekSandeep Před 2 lety

    Engineering Teaching madams are good.....

  • @manojm2099
    @manojm2099 Před rokem

    But we can achieve the same thing by the below method also right?
    int n;
    scanf("%d",&n);
    int arr[n];

  • @richtrader9526
    @richtrader9526 Před 2 lety +1

    Beautiful

  • @anandsonar7590
    @anandsonar7590 Před 2 lety

    Thank you mam for this video
    can you please explain in program of malloc how the pointer returns null
    please????

  • @sridharreddy9742
    @sridharreddy9742 Před 2 lety

    great explanation

  • @prakashreddy773
    @prakashreddy773 Před 2 lety

    Mam i have a doubt
    We can do that with static memory allocation too mam. I observed that here after given the input value of n we can store that n number of values
    Why dont we do this like this using static memory allocation :
    #include
    void main()
    {
    int n;
    printf("Enter the no. Of values do u want to store
    ");
    scanf("%d",&n)
    int arr[n];
    for(int i = 0;i

    • @shuaibjawed1798
      @shuaibjawed1798 Před 2 lety

      we can do it, that's not the point, we are learning dynamic memory allocation not static.

    • @aswinkumarraj5054
      @aswinkumarraj5054 Před 2 lety

      @Shuaib jawed please listen him... He s asking relevant question of this DMA... Same problem I am facing as a learner .. mam please response for this comment... I have posted the same issue in comment section... Pls help us to come out of this issue...

    • @aswinkumarraj5054
      @aswinkumarraj5054 Před 2 lety

      Prakash reddy, u found any solution ??.. pls reply

    • @shuaibjawed1798
      @shuaibjawed1798 Před 2 lety

      @@aswinkumarraj5054 bro the way u are doing is just normal static way, it's not dynamic

    • @aswinkumarraj5054
      @aswinkumarraj5054 Před 2 lety +1

      Yes... The above program was static... But even DMA getting the same result... That s wat I am asking bro

  • @lokesh6828
    @lokesh6828 Před 10 měsíci

    I have a question
    Why we didn't declared the malloc function as
    "void* malloc(size_t size);"
    The real life example can be
    Static memory allocation : Having Rs 10000 from which you can purchase anything but you cannot resell it.
    dynamic memory allocation: having Rs 100000 from which you can rent anything around you and when to return the rented item, you will get full refund and you can use it again and again.

  • @obiorahbryan2243
    @obiorahbryan2243 Před 2 lety +1

    22:13 your real life example was spoken in Hindi.. I don't understand Hindi 😕

    • @disciplined469
      @disciplined469 Před rokem +2

      He is telling that if you are in a hostel and you tell your friend to go into mess and bring 4 to 5 chapatis but you and your friend don't know how how many chapati see you will eat so if he will bring 4 to 5 chabathis and you have eaten only do then rest three are waste so like this is example

    • @obiorahbryan2243
      @obiorahbryan2243 Před rokem +1

      @@disciplined469 ohh thanks so much.

  • @balakrishnan1859
    @balakrishnan1859 Před rokem

    Static memory : Live cricket match (we can't watch the match before or after)
    Dynamic memory:We will watch the match Highlights whenever you want

  • @bheemasamrat
    @bheemasamrat Před 2 lety +1

    Data structure ka practice paper laiye

  • @engr.talhaahmed161
    @engr.talhaahmed161 Před rokem

    i always want to learn about dma concept but dint understand before much , love the way she teaches and it clear all my memory concepts, thank you so much for the video, keep up the good work ma'am

    • @JennyslecturesCSIT
      @JennyslecturesCSIT  Před rokem

      Happy to hear that!

    • @RiteshKumar-pu3gp
      @RiteshKumar-pu3gp Před rokem

      @@JennyslecturesCSIT mam I want to learn c++ language and I covered till DMA so will it be easy to learn or it is entirely different

  • @TEJASPLAYZ
    @TEJASPLAYZ Před 9 měsíci +1

    THANKS 👍👍

  • @sambasivagali9966
    @sambasivagali9966 Před rokem

    ma'am your lookning gorgeous and your lecture too

  • @roshnimandarapu5097
    @roshnimandarapu5097 Před 2 lety

    why should we have to type cast, when generic pointer can take any type of pointer right?

  • @Homelessbillionaire
    @Homelessbillionaire Před 2 lety +2

    Success comes from having dreams that are bigger than your fears.
    Bobby Unser

  • @Lyrics_songs.69
    @Lyrics_songs.69 Před rokem

    I love you ❤️😂
    This is my first class

  • @harshitpal5558
    @harshitpal5558 Před 2 lety

    Mam after allocating 8 bytes if we need more memory like we need to expand that existing memory block then how we can do that

  • @polo4446
    @polo4446 Před 7 měsíci

    In "programming in c" playlist, this is the first video with 1080p quality. But of no use because ma'am looks prettier even in 144p quality😅

  • @dhadhiudayreddy3620
    @dhadhiudayreddy3620 Před 2 lety

    Beauty with brain❤️

  • @unknownindian2142
    @unknownindian2142 Před 2 lety

    Frankly speaking I love you mam❤️😅

  • @Sandeep-sh7uc
    @Sandeep-sh7uc Před rokem

    Mam but pointer variable is used to store only address but why are you using point er variable to store DMA

  • @saikumaryv7004
    @saikumaryv7004 Před 2 lety +1

    mam please make python videos

  • @TusharSharma-vr6hh
    @TusharSharma-vr6hh Před rokem +1

    Mam in same program char pointer i am using instead of using int.
    But the problem is when i give value of n =4
    So i will be able enter two element
    When i give eight as value of n then i will able to enter 4 element.
    Why is it so?
    Why i can't enter element equal to n

  • @farzanaashraf8136
    @farzanaashraf8136 Před rokem

    Mam, You are looking very beautiful in this video, Gorgeous☺

  • @sanjaykumarrana6312
    @sanjaykumarrana6312 Před rokem

    He Jennie kya lag rahi ho yaar ye red colour ka shout me to gajab lag rahi hai, aapki lecture se jyada mujhe aap pasand ho, i love 💕😘 you

  • @preetamkumar8128
    @preetamkumar8128 Před rokem

    Mam can you upload a video for malloc using structure

  • @527_nikhil2
    @527_nikhil2 Před 2 lety

    Mam ur looking very gorgeous 😍❤️

  • @jstar2135
    @jstar2135 Před 2 lety

    Thank You Mam.

  • @godofkings4366
    @godofkings4366 Před 2 lety +1

    thank you very much. but please dont use Hindi inside of a video 😅😅.

  • @Harikesh662
    @Harikesh662 Před rokem

    Chapati example are very 🐎😅😅good chapati

  • @MKO11
    @MKO11 Před 11 měsíci

    pls can you also do a video on big O notation

  • @asrupa7163
    @asrupa7163 Před 2 lety

    Mam I am not interested computer but i am always interested you

  • @sai3099
    @sai3099 Před 2 lety

    Mam please do live lectures

  • @ketankulkarni2286
    @ketankulkarni2286 Před 2 lety

    Good morning madam