Buckys C++ Programming Tutorials - 35 - Passing Arrays to Functions

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ก.พ. 2025
  • Source Code: github.com/the...
    Core Deployment Guide (AWS): docs.google.co...

ความคิดเห็น • 353

  • @shalinisahnimankatalia5305
    @shalinisahnimankatalia5305 5 ปีที่แล้ว +224

    He says loads of times that "How am i going to explain this " and ends up explaining it the best in the world.

    • @entertainingshorts24
      @entertainingshorts24 3 ปีที่แล้ว

      'Best in the world'...really??
      I think u haven't checked other programmers cum teachers on TH-cam.
      He is good, but 'best' signifies Hyperbole ( Atishyokti alankar).

    • @omkarjsuvarna
      @omkarjsuvarna 3 ปีที่แล้ว +5

      @@entertainingshorts24 But he is literally one of the best if you want the explanation to be short, sweet and entertaining as well. I literally watched 30+ videos of his in a single day and still not bored while if I try to watch some other youtuber explaining it I would probably sleep through 1st tutorial itself.

    • @entertainingshorts24
      @entertainingshorts24 3 ปีที่แล้ว

      @@omkarjsuvarna may be...but if u are a hindi speaker then u can also follow Codewithharry.

    • @omkarjsuvarna
      @omkarjsuvarna 3 ปีที่แล้ว +1

      @@entertainingshorts24 Again as I said I want short and sweet explanation to grasp the topic really quickly and once I understood it then I can dive deep to complex programs. For learning basics fast this channel is like a diamond. I've watched tutorials of Codewithharry, but I always stop watching the video after 1 or 2 tutorials. But in this channel, I've never stopped watching it continuously.

    • @svenspajgl9118
      @svenspajgl9118 3 ปีที่แล้ว

      @@entertainingshorts24 shush kid

  • @aditijoshi4240
    @aditijoshi4240 7 ปีที่แล้ว +193

    Prof: gimme some name for the array
    Me: bucky

    • @lastofthestars6481
      @lastofthestars6481 7 ปีที่แล้ว +5

      prof: gimme some name of the array you boy
      me: Aditi joshi
      class: hahahahahhhaa
      prof: get the fuck outta here

    • @sameeralam8829
      @sameeralam8829 5 ปีที่แล้ว +5

      @Shallex little virgin let him laugh

    • @cabreram.4734
      @cabreram.4734 5 ปีที่แล้ว +2

      Sheez 🤦🏻‍♂️ these virgins are so cringy

    • @devidkarki1875
      @devidkarki1875 5 ปีที่แล้ว +2

      For real for real

  • @Trxgger_T
    @Trxgger_T 7 หลายเดือนก่อน +4

    Crazy how this tutorial is still as informative 13 years later. Preciate the good work 👏

  • @ADwaMoviesandMusicsproduction
    @ADwaMoviesandMusicsproduction 4 ปีที่แล้ว +4

    Thank you a million times, I watched like 100 videos for this. I even watched your videos like 10 times but didn't understand because I already belived that it's so hard. And now understand everything from 6:30 to 7:30? Thanks a lot, my home work and project was due to 3 days later. didn't know it's easy.

  • @martyyoung
    @martyyoung 11 ปีที่แล้ว +15

    I have watched 20 or so and some a couple of times just to get it through my head. Great stuff!!!!!

  • @salmaalfawal6155
    @salmaalfawal6155 4 ปีที่แล้ว +2

    8 mins of Bucky's tutorials VS 2 whole lectures

  • @killaburribo
    @killaburribo 3 ปีที่แล้ว +6

    literally saving my semester 😭👌🏼

    • @dark-_-001-kys
      @dark-_-001-kys 3 ปีที่แล้ว

      which semester brother i mean in which semester it was asked

  • @Faith-sf2fi
    @Faith-sf2fi 4 ปีที่แล้ว

    These quick videos teach me so much better & faster than my professor and the “teaching” program he makes me buy which mind you is expensive !

  • @ucheezih1416
    @ucheezih1416 12 ปีที่แล้ว

    This guy really knows what he's teaching...Two topics in C++ that I found difficult to understand(Multidimensional array and this right here- passing arrays into Functions), he really demystified it all...Even in an easy to understand manner...10x bro...

  • @fatima-oy7gk
    @fatima-oy7gk 4 ปีที่แล้ว

    Wow. I was super stressed. I couldn't understand no matter how many tutorials I watched. Now I do Alhamdolilah. Thank you so much.

  • @10YardCricket
    @10YardCricket 8 ปีที่แล้ว +11

    He explains everything so much that during 5: 03 he was out of explanations .. Legend

  • @luyuwang379
    @luyuwang379 5 ปีที่แล้ว +2

    Bucky, one of the best teacher for programming !

  • @mituldesai9807
    @mituldesai9807 9 ปีที่แล้ว

    Excellent class..had no problems understanding whatsoever..u r a lifesaver!!

  • @jpsplat
    @jpsplat 7 ปีที่แล้ว +2

    This video helped me a bunch on my homework. Thank you!

  • @rubbeldiekatz85
    @rubbeldiekatz85 12 ปีที่แล้ว

    thanks man. I wracked my brain about how to put an array into a function. Now my programm is running. I appreciate your help.

  • @hefhef54321
    @hefhef54321 8 ปีที่แล้ว +6

    You know, I've been messing around with arrays and I discovered that you can create an even cooler RNG program using arrays.
    All you have to do is create a for loop where the value of each element in the array is assigned to a seeded random number.
    Here's an example:
    #include
    #include
    #include using namespace std;void romba(int Input[], int Size);int main()
    {
    cout > y; int fofo[y];
    srand(time(0)); for(int x = 0; x < y; x++){ fofo[x]= rand()%y;
    } romba(fofo, y); return 0;
    }void romba(int Array[], int Size){for(int x = 0; x < Size; x++){ cout

  • @odo432
    @odo432 11 ปีที่แล้ว

    For someone who's never said WOW in their life you certainly said it a lot in your post.

  • @ivanbeltran-salazar117
    @ivanbeltran-salazar117 8 ปีที่แล้ว +2

    Great tutorial cleared up the basics

  • @odorlessflavorless
    @odorlessflavorless 5 ปีที่แล้ว +3

    We went from 360p to 4K in 7 years! Amazing!

  • @KydroxHD
    @KydroxHD 8 ปีที่แล้ว +6

    i listen to this in 1.5 speed, its actually pretty efficient

  • @lmao3295
    @lmao3295 8 ปีที่แล้ว

    this really confused me for a bit but thanks to you i get it now c:

  • @OceanageMangoma-w4p
    @OceanageMangoma-w4p ปีที่แล้ว

    woww thanks you really helped me a lot, l got a final tomorrow 🔥🔥🔥🔥

  • @misterimpossible_ai
    @misterimpossible_ai 9 ปีที่แล้ว +1

    I love how you teach.

  • @Qazqi
    @Qazqi 12 ปีที่แล้ว

    I'm not quite sure what you're asking, but that statement is fine, provided the variables all have a value.

  • @KeepOnCoding
    @KeepOnCoding 10 ปีที่แล้ว +1

    Actually, the reason you don't pass bucky with square brackets is because it is a pointer to the first element of the array.
    You cannot pass the whole block of an array as an argument (mainly because it's very slow to copy the entire array), so you just pass the address of the first element.

  • @syedsamiullah6573
    @syedsamiullah6573 3 ปีที่แล้ว

    Video almost a decade ago helped me today..😘😘

  • @puvistyne28
    @puvistyne28 8 ปีที่แล้ว

    Thank you very much...exactly what i expected

  • @arbazkhalid8249
    @arbazkhalid8249 6 ปีที่แล้ว

    great : i a'm confused how to use array but now i'm happay after your tutorial.

  • @hashcodez757
    @hashcodez757 2 ปีที่แล้ว

    great work sir !!
    hats off to you

  • @123455866201Aaron
    @123455866201Aaron 5 ปีที่แล้ว

    TH-camr guides > Your uni lecturer

  • @iXenoCider
    @iXenoCider 13 ปีที่แล้ว

    Yes lol, I know, I gave you the link to this video! :D, glad it helped! Goodluck on your coding!

  • @Genuigr
    @Genuigr 12 ปีที่แล้ว +1

    Little tip for you guys: you can get the length of an array by using this:
    int length = sizeof(array) / sizeof(/*arraytype eg.:*/ integer)

  • @azstudioproductions
    @azstudioproductions 13 ปีที่แล้ว

    You have been helping me so much ! Thank you so much !

  • @alexandersamudra6822
    @alexandersamudra6822 2 ปีที่แล้ว

    one of the best explain 👍

  • @Daniel7681
    @Daniel7681 10 ปีที่แล้ว +1

    Thanks for making these. :)

  • @tokhirbekorifjonov2200
    @tokhirbekorifjonov2200 3 ปีที่แล้ว

    very good and clear explanation thank you very much

  • @river6634
    @river6634 8 ปีที่แล้ว +252

    It annoys me that he keeps asking "What is going on guys?" but doesn't give us time to answer.

    • @QrUpload
      @QrUpload 7 ปีที่แล้ว

      hahhaa nice one bro !

    • @rolarola5915
      @rolarola5915 7 ปีที่แล้ว +1

      hhhhhhhhhhhhhhhhhhhhh same thing XD

    • @nickbossbg5636
      @nickbossbg5636 7 ปีที่แล้ว

      xDDDDDDDDDDDDD

    • @SkeeNnN
      @SkeeNnN 7 ปีที่แล้ว +3

      when you realize you have no social life

    • @hananeikh
      @hananeikh 6 ปีที่แล้ว +5

      u can just pause and answer it to urself

  • @karthikeyanb6016
    @karthikeyanb6016 7 ปีที่แล้ว

    amazing bro....... thank u soo much.... u have made this very easy to understand...... ty bro

  • @EPKX
    @EPKX 11 ปีที่แล้ว

    yes you have to tell the computer that the elements in the array are integers, it makes sence too since array is nothing but a variable that can have different values at different time depending on the input, we treat x[ ]
    the same way we treat x

  • @Shawn_White
    @Shawn_White 7 ปีที่แล้ว

    I'm using G++ as a compiler and it works even without the prototype.

  • @winnermsigwa4922
    @winnermsigwa4922 2 ปีที่แล้ว

    Thanks ..and be blessed🙏

  • @nukacoaal
    @nukacoaal 8 ปีที่แล้ว +2

    as an options, you can use a vector for this sort of thing, so you won't need to use second variable "sizeofarray".
    but probably it is more advanced lvl.

  • @knuhuf2
    @knuhuf2 8 ปีที่แล้ว

    use sizeof(nameOfArray) to determine the size of an array. This gives you the size in bytes so just divide it by the size of each element in your array, e.g int, float, long = 4 and double = 8.
    I'll throw in an example:
    int myArraySize = sizeof(myArray)/4;

  • @onurkirec5784
    @onurkirec5784 11 ปีที่แล้ว

    I wish there were some manner tutorials for guys like you.

  • @iXenoCider
    @iXenoCider 13 ปีที่แล้ว

    Its the name of a book, "C++ for Dummies", they have a TON of books like "C# for dummies", "Karate for Dummies", FILLINWORDHERE "For Dummies".

  • @YounesKeraressi
    @YounesKeraressi 13 ปีที่แล้ว

    bucky,you still the best

  • @omarimtiaz8211
    @omarimtiaz8211 9 ปีที่แล้ว

    thanks bukky ur tutorials are helpful

  • @gijimbo1337
    @gijimbo1337 9 ปีที่แล้ว

    FYI (not sure if anyone else has mentioned this yet) if you don't want to worry about the array sizes or don't know the array sizes, look into using vectors.

  • @td4269
    @td4269 8 ปีที่แล้ว

    This is so useful. Thank you

  • @wafflez9888
    @wafflez9888 8 ปีที่แล้ว

    Thanks Bro T T You even care about us more than our teachers do!! (Watch out,Don't forget. You're pro with this) Like seriously Thanks bro!

  • @Chriscs7
    @Chriscs7 13 ปีที่แล้ว

    NICE TUTORIALS BUCKY! BUT INSTEAD OF PROTOTYPING FUNCTIONS YOU CAN JUST WRITE THEM BEFORE THE MAIN FUNCTION SO YOU DONT NEED TO COPY THE HEADER,IT WORKS FINE THAT WAY TOO.

  • @NBA2KLTT17
    @NBA2KLTT17 6 ปีที่แล้ว

    Besides LeBron, you are the GOAT.

  • @Michy20
    @Michy20 6 ปีที่แล้ว

    OMG you saved me! very useful!

  • @Classic112
    @Classic112 11 ปีที่แล้ว

    the best way to explain why you don't need to label it as an array is because in your prototype you are calling for an array so it will automatically look for an one.

  • @jessicapeters3533
    @jessicapeters3533 7 ปีที่แล้ว

    First time I've seen my name as a variable - woo! :)

  • @ceciliaamoako9694
    @ceciliaamoako9694 5 ปีที่แล้ว

    You are a lifesaver

  • @stephanschultz7560
    @stephanschultz7560 5 ปีที่แล้ว +18

    if you put the main function under the void function, you won't get an error message and will work just fine.

  • @InstAmateur
    @InstAmateur 11 ปีที่แล้ว

    The holy oPryze has learned from Master Bucky!

  • @Boomerlance
    @Boomerlance 13 ปีที่แล้ว

    Got it!
    thanks again,dude :)

  • @Dukekilo
    @Dukekilo 8 ปีที่แล้ว +80

    His folder name is Watermelon........hahahahah

    • @TheWarfare07
      @TheWarfare07 7 ปีที่แล้ว +3

      my folder name is tits......hahahaha

    • @Linkyamato
      @Linkyamato 6 ปีที่แล้ว +1

      FUCK

  • @lobnahamdi4660
    @lobnahamdi4660 7 ปีที่แล้ว

    thank you !! you are the best :))))

  • @jblackwell1014
    @jblackwell1014 11 ปีที่แล้ว +4

    ahhh Jessica... the one that got away

  • @shazaibmaqsood2957
    @shazaibmaqsood2957 5 ปีที่แล้ว

    bucky jani tu love ha

  • @soggy9648
    @soggy9648 4 ปีที่แล้ว

    fucking legend. my final now looks possible fucking life saver

  • @flow1465
    @flow1465 8 ปีที่แล้ว +2

    For anyone thinking where they can use arrays.
    Here is one example of it:
    #include
    using namespace std;
    int multiman (int sizeit);
    int main()
    {
    int nub;
    cout

    • @flow1465
      @flow1465 8 ปีที่แล้ว +1

      ***** Okay, thanks.

  • @TheaDragonSpirit
    @TheaDragonSpirit 12 ปีที่แล้ว

    Can't get the Bucky O Hare song out my head now. Ha.

  • @Globox822
    @Globox822 11 ปีที่แล้ว +1

    bad ass bucky, thx

  • @beetlesss2560
    @beetlesss2560 5 ปีที่แล้ว

    Fuck this... I'm in civil engineering and we have this... Harder than calculus!

  • @colouredmirrorball
    @colouredmirrorball 13 ปีที่แล้ว

    Apparently there is no function to return the length of an array in C++. If you want to use the length of an array, you need to use sizeof(*name of your array*) / sizeof(*name of your array*[0]). Sizeof() returns the number of bits a variable has, so if you had an array consisting of integers, and your array had 20 elements, the size of your array would be 80 as the size of an integer is 4.

  • @hrbharry
    @hrbharry 11 ปีที่แล้ว

    Normally you don't want to copy the entire array, you use a pointer. And the array should be allocated on the heap anyways

  • @onelerv1
    @onelerv1 13 ปีที่แล้ว

    @Chriscs7 Its better programming practice to write a prototype away from the body of the function, you'll see later on, it makes the code easier to read as well as makes the function more encapsulated which is very important as a programmer.

  • @herp_derpingson
    @herp_derpingson 12 ปีที่แล้ว +2

    :O
    *Jaw Dropped*

  • @subs2meplease
    @subs2meplease 13 ปีที่แล้ว

    Try printing an array through the function with more indices than it has. You won't get a compiler error ;)

  • @Ooblec
    @Ooblec 3 ปีที่แล้ว

    This guy is good😃😃

  • @bayroncastillo7653
    @bayroncastillo7653 6 ปีที่แล้ว

    what a great video

  • @TheWarfare07
    @TheWarfare07 7 ปีที่แล้ว

    very nice. thanks

  • @4ThaCulture
    @4ThaCulture 12 ปีที่แล้ว

    No, an array has all of the same type of data. Hence, here the datatype is integer. If you wanted to do the alphabet you would probably use char array[] etc, but it can't mix numbers and characters. Hope this helps@Zakareya Alatoli

  • @dickdastardly4835
    @dickdastardly4835 6 ปีที่แล้ว

    When I run jessica with a size greater than the functions size, it starts showing bucky's integers, but the reverse does not happen. What causes this?

  • @瑠ちゃん
    @瑠ちゃん 10 ปีที่แล้ว +1

    if you change the size of the array in the function to greater than the actual size of the array you get the values of the other arrays, I think it shows you what is in that slot of the ram, a bit like the heartbleed bug

  • @Qazqi
    @Qazqi 12 ปีที่แล้ว

    C++ arrays don't have a Length property (or properties in the C# sense at all). For known sizes, it's best to use std::array, and for dynamic arrays, it's best to use another standard container, std::vector being a good one for general use.

  • @user-cf7vy4hl8p
    @user-cf7vy4hl8p 11 ปีที่แล้ว

    You aren't wrong when you state that "the reason why an array when called within main isn't using square brackets, is because the name of the array is "Jessica", That was just a little vague,More over it is because the function has taken the parameter of an array first. ex: "void blahblah(int whatever[ ], int sizeofarr)" so when called it will expect the first parameter you type to be the array. If you had passed the size and then the array ex:"(size, arr)"the program most likely not know what you are referring too.
    Correct me if i am wrong, if this helped Then You're Welcome.

  • @danbreland3444
    @danbreland3444 7 ปีที่แล้ว

    Jessica 6 is the name of the main female character in the Logan's Run movie.

  • @jyotiprakashnath1118
    @jyotiprakashnath1118 2 ปีที่แล้ว

    Really helpful

  • @jakubircow6875
    @jakubircow6875 9 ปีที่แล้ว

    when calling the function, do you put the position of a value in the array in the square brackets when you want to pass the position instead of the whole array ?.

  • @JCStelu
    @JCStelu 8 ปีที่แล้ว

    Somehow, I think it's a good practice to make sizeOfArray a const, just to avoid future changes into, that is to avoid getting funny things from compiler if you change by mistake the size of array in your external function.
    void foo( std::string name[ ], const int n) { ... }

  • @aaron171091
    @aaron171091 10 ปีที่แล้ว

    hi, i want to implement an application that reads a file, modify its content and write the modification back to the same file? how i can do that? would u please give me some hint?

  • @abodisom_official
    @abodisom_official 11 หลายเดือนก่อน

    Nice video

  • @thehacker8454
    @thehacker8454 6 ปีที่แล้ว

    Do you have to put the number of elements in the square brackets or can you just leave them empty?

  • @chrisp.401
    @chrisp.401 7 ปีที่แล้ว +9

    When I make sizeOfArray bigger than it actually is, it steals the value of arrays that were declared before. example:
    int amazingArray[5] = {16,19,22};
    int unrealArray[2] = {69,96,666};
    realityBreakingFunction(unrealArray, 7);
    output:
    69
    96
    666
    16
    19
    22
    WHAT"S GOING ON GUYS?

    • @yassinghareeb4074
      @yassinghareeb4074 7 ปีที่แล้ว

      interesting

    • @HaraldSangvik
      @HaraldSangvik 6 ปีที่แล้ว

      You're accessing memory after that array. All sorts of shit can happen :)

    • @HermanWillems
      @HermanWillems 6 ปีที่แล้ว

      These C++ lessons are awfull and it uses OLD C++. Nobody in the right sense uses regular Arrays. Everybody uses STD::ARRAY It's an containered array. It's safer, got more handy futures build in and just as quick.
      I defined the size of the array in an oldfasioned way like this:
      int bucky[3] = { 2,95,304 };
      int jessica[6] = { 45,46,78,34,45,2 };
      printArray(bucky, sizeof(bucky) / sizeof(bucky[0]));
      printArray(jessica, sizeof(jessica) / sizeof(jessica[0]));
      // Number of elements are total size of array divided by the individual sizes of the elements, because different types use different memory sizes.

  • @leeonzo4535
    @leeonzo4535 2 ปีที่แล้ว

    Ok when I do it they change my array values to extreme values
    I changed the array from double to integer and still with the changing values
    What do you think is up with that

  • @benjaminhao7965
    @benjaminhao7965 6 ปีที่แล้ว +1

    I have one question. When I define the function printArray before main function, I don't really need to prototype printArray (i.e. Declaration). The program run fine and I got no error or warning messages. How does that even work? Thx!

    • @tanyichun2535
      @tanyichun2535 4 ปีที่แล้ว

      computer programs read the code from top to bottom, the reason why you need to prototype a function is because the function is defined after the main function, so the computer would have no idea what the function is since it hasn't read the function yet, that's why you need to prototype the function to let it know beforehand that this function will be defined later after the main function. if you define the function before the main function then there's no need to prototype it because the function has already been read before the main function.

  • @mohdad-fadhilmusa8394
    @mohdad-fadhilmusa8394 4 ปีที่แล้ว

    I don't understand, the variable x is not declared in the program but there is no error?????

  • @emmanuelu
    @emmanuelu 4 ปีที่แล้ว

    this video came out when i turned
    11. i feel old.

  • @josiftepegjozov3144
    @josiftepegjozov3144 10 ปีที่แล้ว

    Thank you so so much :DDDDDDDDDD

  • @kjw21411
    @kjw21411 9 ปีที่แล้ว

    I'm trying to make a card game and shuffle the cards, then deal them (3 cards will be dealt per play), but I keep getting multiple duplicate values for the shuffled and dealt cards. The values in the array are 0 - 51, each of which represent one of the 52 cards. Here are the two functions. top is the top card in the deck array and numCards keeps track of how many cards have been dealt.
    void shuffle(int numCards, int deck[ ]) {
    for (int top = 0; top < 52; top++)
    {
    int r = rand() % 52;
    int temp = deck[top];
    deck[top] = deck[r];
    deck[r] = temp;
    cout

  • @WolfySnackrib666
    @WolfySnackrib666 12 ปีที่แล้ว

    What if you had an int named the same thing as the array, how would it know to pick the array and not the int?

  • @niranjanpradhan3364
    @niranjanpradhan3364 10 ปีที่แล้ว

    Hello Sir, Array can be overloaded or not,that means if we take two array with same name but different number of parameter,and we pass it through function call then it was not working.

  • @emrekazoglu4461
    @emrekazoglu4461 5 ปีที่แล้ว

    what if we had a integer which named as bucky how it is going tounderstand we are talkng about bucky which is array? could you help me

  • @TheaDragonSpirit
    @TheaDragonSpirit 12 ปีที่แล้ว

    Do you still need to add the 'Int' on the real function not the prototype?

  • @babylongate
    @babylongate 11 ปีที่แล้ว

    A Canadian is walking down the street with a case of beer under his arm.
    His friend Doug stops him and asks, "Hey Bob! Whacha get the case of beer
    for?"
    "I got it for my wife, eh." answers Bob.
    "Oh!" exclaims Doug, "Good trade."