malloc vs calloc - mysirg.com | Interview Question

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 111

  • @swarnavachatterjee9303
    @swarnavachatterjee9303 7 лет назад +47

    HIT LIKE IF U CONSIDER SAURABH SIR AS THE BEST C TEACHER

  • @pradeepkushwaha4786
    @pradeepkushwaha4786 5 лет назад +1

    Sir you are doing good work...
    Well done .... tnx you so much sir

  • @ngnd5065
    @ngnd5065 7 лет назад +4

    you are great sir

  • @professorpoke
    @professorpoke 3 года назад

    malloc(10*sizeof(int))
    It allocates a memory block of size 40 bytes.
    calloc(10, sizeof(int))
    It allocates 10 contiguous memory blocks each of size 4 bytes.

  • @mramanyadav9826
    @mramanyadav9826 2 года назад

    Thank you sir, love your explanation

  • @manas07867
    @manas07867 5 лет назад +1

    Nice explaination sir...my like number 400☺️

  • @ankitcaring
    @ankitcaring 7 лет назад +1

    Awesome explanation sir

  • @b_01_aditidonode43
    @b_01_aditidonode43 8 месяцев назад +1

    crystal clear sir!!

  • @shalinikatore1161
    @shalinikatore1161 3 года назад +1

    Sir but when we pass in malloc only any numerical value like 10 .
    And we say malloc is DMA but when we pass any numerical value instead of taking input by user.
    That time, can we say it is dynamically allocated?

  • @rishutoshniwal3561
    @rishutoshniwal3561 4 года назад

    What will be the value initialized by calloc if dynamically created variable are not of primitive type?

  • @yashsingh6793
    @yashsingh6793 7 лет назад +1

    Bhut sahi sir

  • @GurpreetSingh-th1di
    @GurpreetSingh-th1di 7 лет назад +2

    Sir thanks for the video

  • @ashishsingla2666
    @ashishsingla2666 7 лет назад +1

    nice video sir

  • @kulwinderbhatoa5578
    @kulwinderbhatoa5578 7 лет назад +2

    Sir structure ke upar videos bnao plss

  • @irajatpandey
    @irajatpandey 7 лет назад +1

    Thank you sir... for this video
    can you use digital writing pad and try to explain all the future content by using that... it will be very helful for us.. to grasp the concept ..
    i have seen lots of tutorials on coursera, Udemy, Lynda they use digital Pad...
    they are good but u r just amazing... Hindi mei padhne ka maza he kuch aur hai...
    and the content is marvellous and unique....😊

  • @arushisinghonelove9394
    @arushisinghonelove9394 7 лет назад +2

    thanks sir..

  • @yourjeedost9014
    @yourjeedost9014 4 года назад +1

    Sir, I was looking for the video under this title as I wanted to confirm the difference that whether malloc initializes with no default value, but calloc initializes with zero value by default. Is it true?

    • @professorpoke
      @professorpoke 3 года назад

      In malloc values at allocated memory are initialised by garbage value
      In calloc values at allocated memory are initialised by 0

  • @tejbahadurkhatri4762
    @tejbahadurkhatri4762 3 года назад

    Thank you sir

  • @kunalchaudhari893
    @kunalchaudhari893 5 лет назад

    could you please explain what is the actual difference in malloc and calloc in terms of it allocates the DMA? if we multiply size of () in malloc with 10 and in calloc if we pass first argument 10 then what will be the difference. It will allocate the same size according i understand but then what will be the difference ?

    • @professorpoke
      @professorpoke 3 года назад

      malloc(10*sizeof(int))
      It allocates a memory block of size 40 bytes.
      calloc(10, sizeof(int))
      It allocates 10 contiguous memory blocks each of size 4 bytes.

  • @prateekjaiswal8849
    @prateekjaiswal8849 6 лет назад

    sir why peek returns (top-1) during dynamic stake programs

  • @shahdivya8775
    @shahdivya8775 7 лет назад

    Thanks for this video...sir...

  • @VinodThakur-i4i
    @VinodThakur-i4i 6 лет назад +4

    sir plzz make campus preparation videos also for c++

    • @mysirgdotcom
      @mysirgdotcom  6 лет назад

      visit www.mysirg.com for campus content

  • @azadmhd
    @azadmhd 7 лет назад +1

    Sir operating system ke video bnaie plz

  • @kashshafanwartaha2845
    @kashshafanwartaha2845 7 лет назад +1

    achi viedo ha

  • @er.ramsirwithtech2008
    @er.ramsirwithtech2008 7 лет назад

    Thanxx sir ji

  • @icoderwasien
    @icoderwasien 4 года назад

    Sir what is memory management?

  • @hitesh7428
    @hitesh7428 7 лет назад +1

    sir, can you provide the PYTHON course online .......PLEASE sir.

  • @akshayagarwal7764
    @akshayagarwal7764 7 лет назад

    Thanks sir

  • @cookthecode4890
    @cookthecode4890 7 лет назад

    nice video

  • @sanketdarekar8152
    @sanketdarekar8152 5 лет назад

    How the free func. Know that if two ptr with same name then which memory block to free

  • @shaileshshekhar8726
    @shaileshshekhar8726 7 лет назад

    Sir I can not find your video of prepration for MCA enterance exam..sir please give me link for study.

  • @rahulsahu6652
    @rahulsahu6652 7 лет назад

    Sirji c++ sikhne ke liye kon sa book achcha rhega........

    • @vipulsingh9875
      @vipulsingh9875 7 лет назад +1

      Go with Ravichandran's book on C++. Trust me brother this book is amazing for c++.

    • @SonuSonu-tk5pk
      @SonuSonu-tk5pk 7 лет назад +1

      balaguruswamy , c++ primer are good books .. u can also try cplusplus.com , tutorials points
      and when u learn all these then try the book by bjarne stroustrup the creater of c++(but this book is too hard for a beginner)

  • @sairajdas6692
    @sairajdas6692 7 лет назад +2

    Lekin sir apny malloc( ) sy hi dynamic array bnay h data structures ki videos may 😮

  • @arpitmore629
    @arpitmore629 7 лет назад +9

    sir java me interview question dalo jaldii se like

  • @DheerajKumar-wz3wi
    @DheerajKumar-wz3wi 7 лет назад

    When will u upload Advanced lecture of android

  • @surajnegi8022
    @surajnegi8022 7 лет назад

    SIr plz ye btaete ki alg alg bit k compiler mr kaisr decide hota h ki int char float double ko kitni byte memory milege. Plz sir

    • @cookthecode4890
      @cookthecode4890 7 лет назад +1

      i'ts depend on the compiler not on the computer like if you are using a turbo compiler then int has 2 byte and if some other compiler like gcc int take 4 byte

    • @surajnegi8022
      @surajnegi8022 7 лет назад

      But saurav sir khte h ki 16 bit dos arcitecture me int 2 byte 32 bit dos me 4 byte hota h and so on.. To is hisab se to humare o. S se decide hora h ki datatype kitni memory lega na ki compiler.

    • @cookthecode4890
      @cookthecode4890 7 лет назад +1

      sizeof(int) is not a constant across all platforms. It varies from system to system or compiler to compiler.
      Only sizeof object which is constant across all platforms is sizeof(char) [sir is also right]

    • @surajnegi8022
      @surajnegi8022 7 лет назад

      Plz thoda simple way me smjana bhai.

    • @vipulsingh9875
      @vipulsingh9875 7 лет назад

      You can find the size of different data types by sizeof(data_type) operator.

  • @sarveshpandey8900
    @sarveshpandey8900 7 лет назад +1

    thanku sir.......

  • @lakhansihag8885
    @lakhansihag8885 7 лет назад

    Sir Main function return int value in c++ why

    • @cookthecode4890
      @cookthecode4890 7 лет назад +1

      just to tell the operating system that the program is executed properly

    • @lakhansihag8885
      @lakhansihag8885 7 лет назад

      Then why main function is not give void type value

    • @cookthecode4890
      @cookthecode4890 7 лет назад +1

      The same way as a function in your program may returns values to indicate its result, main returns to indicate the result of execution of your program. also in case int main() does return explicit, compiler will put return 0 automatically

    • @cookthecode4890
      @cookthecode4890 7 лет назад

      www.geeksforgeeks.org/fine-write-void-main-cc/ read this

    • @lakhansihag8885
      @lakhansihag8885 7 лет назад

      Thanks sir

  • @azadmhd
    @azadmhd 7 лет назад

    c++ fatal error no such file or directory... sir ye problem kese solve hogi

  • @sofiamyfirstbook3988
    @sofiamyfirstbook3988 Год назад

    Jay bheem namo buddhay jay bharat

  • @DheerajKumar-wz3wi
    @DheerajKumar-wz3wi 7 лет назад

    I am writing from lot's of time

  • @gauravnagar3712
    @gauravnagar3712 7 лет назад

    Sir mana 2 management system bana rkhe h java se .but kuch aur tarah ka kya ban sakta hai management system ka alawa samj nhi aa RHA.

    • @cookthecode4890
      @cookthecode4890 7 лет назад

      you can make web application like paint application, key logger, web browser, music player

    • @gauravnagar3712
      @gauravnagar3712 7 лет назад

      Cook The Code all these are already made up and much better than what I can make

    • @cookthecode4890
      @cookthecode4890 7 лет назад

      may be it's quite high project but i am also make a project in machine learning using python the project is same as google voice capture . you can input a data in form of voice like i am saying [tell me something about c++ ] so he search the web and gave the result in from of voice and all the api i am building my self but it's quite a difficult project i am with 3 other people working on this project if you have a group of 3-4 people you can also make something like this

    • @gauravnagar3712
      @gauravnagar3712 7 лет назад

      Cook The Code I am alone here to make project

    • @gauravnagar3712
      @gauravnagar3712 7 лет назад

      Cook The Code I m unable to understand what other things can we make with java swing

  • @amitsinghaniya9684
    @amitsinghaniya9684 7 лет назад

    sir premium.my sirg.com kb Star hoga

  • @MrUmang40
    @MrUmang40 7 лет назад

    Sir Mera doubt ye Hai k agar ma char* a = (char*)malloc(6*sizeof(char)); karta Hun memory allocation character pointer k liye......to pahla index.....I mean a[0] ko print karwata Hun to hamesha null value aati Hai......I mean agar allocation k pad ma data input karaun......aur print out lun......to hame pahla alphabet index 1 SE start hota Hai na ki index 0 se...
    Sir please look into this.....aisa kyun hai

    • @cookthecode4890
      @cookthecode4890 7 лет назад

      #include
      #include
      int main() {
      char* ptr=(char*)malloc(6*sizeof(char));
      scanf("%s",ptr);
      for(int i=0;ptr[i];i++)
      printf("%c ",ptr[i]);
      }
      check out this i don't think there is any problem index always start from 0

    • @vipulsingh9875
      @vipulsingh9875 7 лет назад

      treat 'a' as ponter but not as array. i did the same thing what you asked and i got the desired output too in the code blocks ide

    • @MrUmang40
      @MrUmang40 7 лет назад

      yeah index starts with 0 with ptr[0] will give 0 and the first character always starts with index ptr[1]...

    • @MrUmang40
      @MrUmang40 7 лет назад

      you mean *(a+0) this to be printed out

    • @MrUmang40
      @MrUmang40 7 лет назад

      its not gonna solve the problem man

  • @awareindia6361
    @awareindia6361 6 лет назад

    Why the malloc bidefault value is garbage?? And say about calloc also

  • @pardeepsaini1634
    @pardeepsaini1634 7 лет назад

    struct student
    {
    int x;
    structure student *p;
    };
    F1()
    {
    struct student *m;
    m=(struct student)malloc(8);
    }
    Sir F1 Function me m variable behave like a SMA variables Ya DMA variable.

    • @aabid3375
      @aabid3375 5 лет назад

      SMA because it is declared above.

  • @DheerajKumar-wz3wi
    @DheerajKumar-wz3wi 7 лет назад

    Sir please upload android lecture

  • @arpitmore629
    @arpitmore629 7 лет назад

    java

  • @fectnamdev6625
    @fectnamdev6625 6 лет назад

    Thanks sir