C++ POINTERS (2025) - How to create/change arrays at runtime? (Dynamic arrays) PROGRAMMING TUTORIAL

Поділитися
Вставка
  • Опубліковано 14 гру 2024

КОМЕНТАРІ • 284

  • @CodeBeauty
    @CodeBeauty  3 роки тому +23

    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.

    • @DanTon-v7o
      @DanTon-v7o Рік тому

      Thank you so much for your lecture. It's very good and it helps me alot.
      I have a question regarding to deallocate memory: What if we don't call delete[]myArray but just only call myArray = NULL; ? Can you explain what will happen?

  • @uccoskun
    @uccoskun 11 місяців тому +11

    You are a very good teacher. you specify the problem, explain it, and then finally solve it for us.

  • @robertocarriero
    @robertocarriero 3 роки тому +47

    I do love your pronunciation! For a non native english speaker (like me), it is very easy to understand you :-)

  • @tep-gn4rk
    @tep-gn4rk 3 роки тому +50

    Thank you! I was so frustrated by my dynamic arrays assignment in class, I spent hours trying to get it to work. This helped clear things up! :)

  • @jahitrst2863
    @jahitrst2863 4 роки тому +52

    Aight. Finally something good on UA-cam

  • @srivathsgondi191
    @srivathsgondi191 3 роки тому +2

    i have followed so many coding channels, yet this remains as one of the best for me.

  • @snazzym00se
    @snazzym00se 3 роки тому +12

    This was way more helpful than my lecture videos for class. Thank you

  • @sinodasidiatof5465
    @sinodasidiatof5465 3 роки тому +1

    Of all online tutorials, you are the best! Not only in C++. You must teach in universities. Charismatic!

  • @michaelmorrow12
    @michaelmorrow12 2 роки тому +3

    Love your videos! Currently in my last year for my bachelors and have this crazy 7 hour long test at the end of the semester where 1/4 of it tests my c++ knowledge. If I get anything less than a 70 on the test I auto fail no matter what I have on anything else turned in during the semester. Reviewing c++ with your tutorials is seriously boosting my confidence! thank you..

    • @shaquilleoatmeal6588
      @shaquilleoatmeal6588 2 роки тому +2

      7 hours ?
      which country are you from bro?

    • @mariacunha8508
      @mariacunha8508 2 роки тому

      how was your test, sir? also, 7 hours? how do you survive?

    • @sonido9519
      @sonido9519 Рік тому

      what did you get? what are you doing now?

    • @k2305Pawan
      @k2305Pawan 2 місяці тому

      which uni, sounds crazy lol

  • @mohtdips277
    @mohtdips277 4 роки тому +4

    I am very happy when I see you .. I love your lessons very much, although I suffer from an understanding of the English language, but I somehow benefit ... My love for you and I wish you success and excellence ..
    from Palestine

    • @CodeBeauty
      @CodeBeauty  4 роки тому +1

      Thank you so much! 🇵🇸🥰

  • @czaratech7216
    @czaratech7216 2 роки тому +2

    I love how you explain things going on in memory!

  • @careenwasonga
    @careenwasonga Рік тому +1

    I have been binge watching your videos and must I say, THIS ONE RIGHT HERE!!! It made everything make perfect sense.

  • @snehadey883
    @snehadey883 9 місяців тому +1

    Why didn't I find your channel earlier?😩 You explained it very well I understood this topic within seconds ❤

  • @bintangyustra
    @bintangyustra Рік тому

    thank you so much, this video help me alot to finish my school assignment

  • @smDonttakemeseriously
    @smDonttakemeseriously 3 роки тому +1

    From giving up coding to understanding it all. Your channel is amazing .Thank you so much . I promise to buy you coffee with my first salary :)

  • @kolbe6436
    @kolbe6436 2 роки тому +1

    I didn't quite understand this topic when it was taught at school so I am glad that you explained it well here and I was able to understand it. Thank you.

    • @kolbe6436
      @kolbe6436 Рік тому

      @Feev6r Yes, it is.

    • @kolbe6436
      @kolbe6436 Рік тому

      @Feev6r But it depends on the school you attend.

  • @tellator
    @tellator 3 роки тому

    Thank you for your videos. It is much easier for people who are not native English to perceive your speech than other bloggers

  • @jeloi9364
    @jeloi9364 4 роки тому +8

    amazing explanation Saldina!!! TOP!
    are you planning to make a smart pointers video soon??

  • @sogan754
    @sogan754 3 місяці тому

    What I like about those videos is that they are detailed, and if I'm not mistaken, you're using the official cppreference documentation, and that is good because I recognize things from our Professor's lecture. He also uses that site as a source, which makes what is thought detailed and enough, despite most videos that talk about the concepts shortly.

  • @zombiehellmonkeygaming1956
    @zombiehellmonkeygaming1956 4 роки тому +10

    Thank you for the tutorial, it cleared many things up for me. Do you think you could expand on this lesson to explain creating dynamic multi-dimensional arrays at runtime?

    • @CodeBeauty
      @CodeBeauty  4 роки тому +7

      I plan to do multidimensional as well 😊

  • @AnuragYadav-cp9jh
    @AnuragYadav-cp9jh 3 роки тому

    I was frustrated but now i finally found how to declare and enter value in dynamic array thank you.

  • @itsme17717
    @itsme17717 Рік тому +1

    I just find your channel and you save my lots of time🥰🥰🥰

  • @satvikkhare1844
    @satvikkhare1844 3 роки тому +1

    You are a very good teacher. Please continue making videos on C++. PLease make videos on Data structures using C++.

  • @MacysShopLifter
    @MacysShopLifter 3 роки тому +2

    Thanks! Really great video. You explained everything perfectly and with great detail. Had no fluff and was quick.

  • @bara7979
    @bara7979 2 роки тому +16

    First and foremost, thank you for all of these fantastic tutorials. We would appreciate it if you could use the dark mode for future tutorials.

    • @CodeBeauty
      @CodeBeauty  2 роки тому +3

      Thanks. I did that already for later videos 😊

  • @PeacefulMusic-l7o
    @PeacefulMusic-l7o Рік тому

    It was reeeaallyyy helpful, I can't say how much this video means to me. Thanks!!!

  • @baconsledge
    @baconsledge 3 роки тому +1

    Very helpful and professional tutorials!

  • @moizsultan5440
    @moizsultan5440 4 роки тому +5

    Just subbed you today after watching 5 of your vids thanks for putting effort

  • @normalperson1130
    @normalperson1130 3 роки тому +1

    Thank you code beauty. Your way of teaching is really helpful in understanding these c++ topics. Now I feel more confident. Thank you very much.

  • @captainven0m38
    @captainven0m38 3 роки тому

    Well I am totally in love with your way of teaching c++ stuff and specifically I love this tutorial.

  • @mashalmokarar4817
    @mashalmokarar4817 2 роки тому +1

    Ms saldina by far your the best:))))

  • @Utkarsh.Raj.129
    @Utkarsh.Raj.129 3 роки тому +1

    At 4:32, I don't get the problem by taking input of size different everytime...why would it be an error...I'm not getting error..pls look onto this

  • @dubiousend9429
    @dubiousend9429 3 роки тому +2

    simple and easy to follow, love it !

  • @alonalon8794
    @alonalon8794 2 роки тому +1

    I dont get an error when I run the code in 4:27. why is that?

  • @erikchen6883
    @erikchen6883 3 роки тому

    Thank you so much for this video! You are so knowledgeable and can explain better than a college professor.

  • @theboy776
    @theboy776 Рік тому

    Yes this girl explains really good. 😊

  • @eliaspianomusic
    @eliaspianomusic 3 роки тому +1

    Highly appreciate the videos! Thanks for your effort! Greatly explained!

  • @valentineobinikpo5375
    @valentineobinikpo5375 3 роки тому

    Thank you, I finally understand DMA in C++..

  • @dayla8434
    @dayla8434 9 місяців тому +1

    How can someone be that perfect in teaching ! U're so beautiful ilu ❤

    • @CodeBeauty
      @CodeBeauty  9 місяців тому +1

      Thank you so much and I'm happy that my videos help you! ❤️🥰

  • @bassets2450
    @bassets2450 4 роки тому +3

    Great job! Keep it up!
    Also, I wanted to ask you if you're gonna do some GUI tutorials in C++... Your explanations are a golden mine... Don't keep them only for yourself! 😉

  • @georgebentley-ricardo9445
    @georgebentley-ricardo9445 2 роки тому +1

    Thanks for sharing another great lesson, a video for algorithms would be great too. Many thanks 🤓👍

  • @Spaghettaboutit
    @Spaghettaboutit 2 роки тому

    Thanks for this video, I needed it as a refresher/maybe I never learned this(?) - anyhow thanks for making a concise explanation that didn't get long winded.

  • @rishabhsingh-gw3gf
    @rishabhsingh-gw3gf 2 роки тому

    Thank you so so much.... finally understood all my doubts are clear...thank you so much for explaining this in so simple way...👍👍👍😃😃❤️❤️

  • @metaman8662
    @metaman8662 3 роки тому +1

    This is enlightening thank you!

  • @nitinchinmay260
    @nitinchinmay260 2 роки тому +2

    I am not getting an error when I write what you wrote till 4:59 😐😐😐😐😐😐😐😐😐😐

  • @SpaceSurferGod
    @SpaceSurferGod 2 роки тому

    Really nice explanation, thank you!

  • @TheWierdVibe
    @TheWierdVibe 2 роки тому +1

    I have been trying to swap the elements of a dynamically allocated array but the program behaves wierdly of an array which is declared at runtime?

  • @gds1233
    @gds1233 2 роки тому +1

    came here from freecodecamp video. loving your content

  • @corradosteri9150
    @corradosteri9150 2 роки тому +1

    I do not get an error if i don't specify array dimension before compiling, running it and cout sizeof gets the right dimension.

  • @codevanguard
    @codevanguard Рік тому

    great practice on de-allocate

  • @datmapmap7942
    @datmapmap7942 3 роки тому +1

    Thanks for your video. Hoping that you will make a video about linked list someday !

    • @CodeBeauty
      @CodeBeauty  3 роки тому +1

      ua-cam.com/video/HKfj0l7ndbc/v-deo.html
      🤗🤗

  • @Abbas-xd1mc
    @Abbas-xd1mc 3 роки тому

    Best explanation! Much appreciated.

  • @robertod893
    @robertod893 2 роки тому

    Excellent video!

  • @vojtechkozak3328
    @vojtechkozak3328 4 роки тому +3

    Will you do video about std::make_unique and std::make_shared?

  • @iamabdulsami
    @iamabdulsami 3 роки тому

    Thanks a lot for clearing my concepts

  • @gisellegonzalez431
    @gisellegonzalez431 3 роки тому +1

    I love your channel!

  • @Ashishkumar-mj4dh
    @Ashishkumar-mj4dh 3 роки тому

    this video cleared my concept

  • @رضوانناجي-ن5ص
    @رضوانناجي-ن5ص 6 місяців тому

    Amazing your explanation

  • @spicyshizz2850
    @spicyshizz2850 2 роки тому

    9:55 I thought that when we did "new" the array changes from fixed where it was originally one after each other and that's why "myArray+I" would work. But doesn't new make the addresses not continuously right after each other?
    So why does it work with new?

  • @shaladddin5687
    @shaladddin5687 3 роки тому

    Thank you so much, the explanation is really satisfying
    that's all I can say 😄

  • @music1.060
    @music1.060 7 місяців тому

    beautiful teacher and fun programming is best

  • @suyash835
    @suyash835 Рік тому +1

    #include
    using namespace std;
    int main(){
    int size;
    cin >> size;
    int arr[size];
    system("pause>0");
    // return 0;
    }
    So here's was my code and this got me *no errors*, maybe its because of the new versions of C++ but doesn't it oppose the whole concept of dynamic array?

    • @MREng786
      @MREng786 Рік тому

      I was about to comment the same thing.
      I had to get up and check again why I didn’t get error.
      @codebeauty can you please explain?
      Thanks

  • @emmapha4593
    @emmapha4593 2 роки тому +1

    Thank you so much for such amazing videos. I hope you could do videos about “sort” and “iterator”. Thank you

  • @Scrawlerism
    @Scrawlerism 3 роки тому

    Omg a good dynamic array deallocation explanation thank youuuuuu

  • @safiullah34511
    @safiullah34511 Рік тому

    4:15 It works on my IDE but you said that it shows error ... The size of array can be specified at runtime

  • @Javagenusk87
    @Javagenusk87 2 роки тому

    Interesting well explained this was very helpful thank you.

  • @mashalmokarar4817
    @mashalmokarar4817 2 роки тому +1

    I cant say thank you enough👏👏

  • @juangaldo2892
    @juangaldo2892 3 роки тому

    I love you, sorry and thank you for all!! I'm learning a lot!

  • @MarošDočekal
    @MarošDočekal 10 місяців тому +1

    Hi, thanks for video. I have question if it is better to use nullptr compare to NULL ?

    • @CodeBeauty
      @CodeBeauty  10 місяців тому

      It is better to use nullptr 😃

  • @sinterusde8869
    @sinterusde8869 3 роки тому +1

    All In hear is disarray ...
    ...
    ...
    Okay, I'm bad at this. But really, I hated arrays and pointers when I first practiced with them. Your tut is very helpful

    • @CodeBeauty
      @CodeBeauty  3 роки тому

      Happy to hear that! ☺️🤗🤗

  • @prokumar7239
    @prokumar7239 2 роки тому +1

    Question: When I try running the example at 4:31, I do not get the error that the expression must have constant value. The program compiles and runs. After some research I found it may have to do with the compiler language standard, I believe my computer defaults to C99. I was wondering if you had any thoughts on this. I am having some trouble setting the proper language standard. Note: I am using terminal commands to compile (g++ ... ) and run (./my_program) Do programmers usually set a standard before starting a project?

    • @alecmatthews9611
      @alecmatthews9611 2 роки тому

      Same bro! I tried doing the example at that timestamp and it works just fine. I didn't even have to do the dynamic allocation thing. Any idea yet why this works?

  • @shakilmosharrof_1994
    @shakilmosharrof_1994 3 роки тому +2

    Please make videos on Data structures and algorithms in c++

    • @CodeBeauty
      @CodeBeauty  3 роки тому

      I already have some video about data structures ☺

  • @__matthi
    @__matthi 3 роки тому

    Great explanation! Thanks :)

  • @MacysShopLifter
    @MacysShopLifter 3 роки тому

    At 5:36 how did you add // quickly to comment that out?

  • @legolas5684
    @legolas5684 4 роки тому +1

    Great job!

  • @Kazner0h
    @Kazner0h Рік тому

    My VS Code doesn't throw me a warning if I try to dynamically allocate an array without the pointer, like at 4:06 . In fact, it just lets me run the code without issue. Has something changed with C++ since this video? Is it still necessary to use a pointer to create an array of dynamic size?

  • @FunComputerScience
    @FunComputerScience Рік тому

    nice video, helped me lot!

  • @ArpitKumar-yo6up
    @ArpitKumar-yo6up 2 роки тому

    Thank you for the explanation

  • @songhye742
    @songhye742 Рік тому

    Your teach very cleared I love you 😘

  • @khalidessamoudi2291
    @khalidessamoudi2291 3 роки тому

    Really beauty coding

  • @atharvagarwal6412
    @atharvagarwal6412 Рік тому +1

    Is it weird that when I run the code at 4:12 on g++ 13.0.1, I get no errors?

    • @CodeBeauty
      @CodeBeauty  Рік тому +1

      If it's not broken, don't fix it 😁

  • @409_manohar6
    @409_manohar6 2 роки тому

    Hi mam ur the one who motivated me and do u remember me?

  • @ahabdelaal
    @ahabdelaal 3 роки тому

    Thank you . appreciate your effort .

  • @cpprogramming2471
    @cpprogramming2471 3 роки тому +2

    int size;
    coutsize;
    int array[size];
    doing it like this does not give any errors to me. can someone explain.

    • @AangContreras
      @AangContreras 3 роки тому

      Same here. I'm not sure why x.x

    • @yasua7000
      @yasua7000 3 роки тому +1

      Variable length arrays (VLAs) are allowed in C99 and many C++ choose to accept them as well. Try compiling it with stricter warning options and you should see something like "warning: variable length array is used [-Wvla]"

    • @yashjadhav6838
      @yashjadhav6838 3 роки тому

      same

  • @prajwalv2222
    @prajwalv2222 3 роки тому +1

    can you make videos regarding to STL in C++?

  • @farichzineb6162
    @farichzineb6162 Рік тому

    4:31 i dont get any error when i try this the program was running just fine with me and i made the user fill the array with the size they put
    please help i dont understand where the problem is

  • @toastyren3991
    @toastyren3991 3 роки тому

    Very interesting video, you're amazing Saldina ;-) Thank you very much for the time you spend making those videos ;-)

  • @abhisheksharma10600
    @abhisheksharma10600 3 роки тому +1

    what if we used header file #include "bits/stdc++.h" ...i mean this can be used to declare dynamic arrays in which the user can specify the size of array , but i want to to know the concept behind...can you clear this please ? and thanks for making the data structures playlist it is really good !

  • @duyngo3574
    @duyngo3574 4 роки тому

    Excellent. I have a question. Why don't we need the zise of array when we delete? How compiler know how many bytes it need to free? Thank you!

  • @nature-water
    @nature-water 2 роки тому

    Thank you vary much sa for all your video 🙏🙏🙏

  • @mmaranta785
    @mmaranta785 3 роки тому

    Thanks. I learned something.

  • @techgen9516
    @techgen9516 4 роки тому +2

    can you compare some of these concepts and syntax compatible with C? I know since C is not a OOP so one wouldn't expect to see classes there. But concepts like this would be in C as well.. Can you please talk about malloc(), calloc(), free() and realloc(). What is the difference, which one is better in what conditions. etc..

    • @jonathancotner7040
      @jonathancotner7040 3 роки тому

      sense when is C not OOP? if you open a file you initialize a FILE *. if you read from a file you pass in a FILE *, if you write to a file you pass in the FILE *, if you close a file you pass in a FILE *. the only difference, in this case, is that C++ implicitly passes in the FILE * into the functions of a class as it's this pointer. malloc(), realloc(), calloc(), are handled by the new keyword in c++, but can still be used, and the rules for their use don't change regardless. If you allocate with malloc, or reallocate with realloc, you must call free() on that allocated memory. if you new some memory, you must delete the memory, and if you new an array you must call delete[] on the array. These rules also apply to the Win32 API calls that allocate memory, and their allocation and deallocation must use the matching allocation and deallocation functions.

  • @yeadatwunyt8004
    @yeadatwunyt8004 3 роки тому

    Finally. Thank you.

  • @nguyenhatronghieu7455
    @nguyenhatronghieu7455 Рік тому

    I have an excercise where I am given a dynamic array A of strings, I need to implement function foo(string &A, string s) to append the string s to the array A. So if I am not provided with the size of the array, how can I solve this? tysm for any suggestions.

  • @BKYADAV-zm7yv
    @BKYADAV-zm7yv 2 роки тому

    Nice explanation mam thank you so much

  • @aykut8517
    @aykut8517 4 роки тому +1

    thanks for upload ,really helpfull

  • @khoatran6791
    @khoatran6791 8 місяців тому

    can I ask how do you set up so that when you finish the line of code, every words and codes of yours had the spaces between them automatically

  • @Pendyala-sharath
    @Pendyala-sharath 3 роки тому

    What is the extension which is automatically formatting the code?

  • @jorgeguzman6685
    @jorgeguzman6685 2 роки тому

    Using NULL or nullptr is the same thing?

  • @treyglass4883
    @treyglass4883 3 роки тому

    what key switches do you have