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

Поділитися
Вставка
  • Опубліковано 29 січ 2025

КОМЕНТАРІ • 353

  • @shalinisahnimankatalia5305
    @shalinisahnimankatalia5305 5 років тому +222

    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 UA-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

  • @Trxgger_T
    @Trxgger_T 7 місяців тому +4

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

  • @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

  • @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

  • @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...

  • @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 !

  • @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

  • @10YardCricket
    @10YardCricket 8 років тому +11

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

  • @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.

  • @luyuwang379
    @luyuwang379 5 років тому +2

    Bucky, one of the best teacher for programming !

  • @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

  • @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.

  • @mituldesai9807
    @mituldesai9807 9 років тому

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

  • @odo432
    @odo432 11 років тому

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

  • @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.

  • @jpsplat
    @jpsplat 7 років тому +2

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

  • @odorlessflavorless
    @odorlessflavorless 5 років тому +3

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

  • @KydroxHD
    @KydroxHD 7 років тому +6

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

  • @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)

  • @123455866201Aaron
    @123455866201Aaron 5 років тому

    UA-camr guides > Your uni lecturer

  • @ivanbeltran-salazar117
    @ivanbeltran-salazar117 8 років тому +2

    Great tutorial cleared up the basics

  • @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.

  • @Qazqi
    @Qazqi 12 років тому

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

  • @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

  • @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.

  • @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

  • @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.

  • @lmao3295
    @lmao3295 8 років тому

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

  • @misterimpossible_ai
    @misterimpossible_ai 9 років тому +1

    I love how you teach.

  • @arbazkhalid8249
    @arbazkhalid8249 6 років тому

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

  • @Daniel7681
    @Daniel7681 10 років тому +1

    Thanks for making these. :)

  • @azstudioproductions
    @azstudioproductions 13 років тому

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

  • @puvistyne28
    @puvistyne28 8 років тому

    Thank you very much...exactly what i expected

  • @iXenoCider
    @iXenoCider 12 років тому

    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".

  • @onurkirec5784
    @onurkirec5784 11 років тому

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

  • @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;

  • @OceanageMangoma-w4p
    @OceanageMangoma-w4p Рік тому

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

  • @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.

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

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

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

    great work sir !!
    hats off to you

  • @Shawn_White
    @Shawn_White 7 років тому

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

  • @iXenoCider
    @iXenoCider 12 років тому

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

  • @karthikeyanb6016
    @karthikeyanb6016 7 років тому

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

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

    very good and clear explanation thank you very much

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

    one of the best explain 👍

  • @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.

  • @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.

  • @Boomerlance
    @Boomerlance 12 років тому

    Got it!
    thanks again,dude :)

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

    Thanks ..and be blessed🙏

  • @NBA2KLTT17
    @NBA2KLTT17 6 років тому

    Besides LeBron, you are the GOAT.

  • @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.

  • @td4269
    @td4269 8 років тому

    This is so useful. Thank you

  • @omarimtiaz8211
    @omarimtiaz8211 9 років тому

    thanks bukky ur tutorials are helpful

  • @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

  • @InstAmateur
    @InstAmateur 11 років тому

    The holy oPryze has learned from Master Bucky!

  • @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

  • @YounesKeraressi
    @YounesKeraressi 13 років тому

    bucky,you still the best

  • @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.

  • @jblackwell1014
    @jblackwell1014 11 років тому +4

    ahhh Jessica... the one that got away

  • @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?

  • @TheaDragonSpirit
    @TheaDragonSpirit 12 років тому

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

  • @瑠ちゃん
    @瑠ちゃん 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

  • @jessicapeters3533
    @jessicapeters3533 7 років тому

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

  • @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!

  • @Michy20
    @Michy20 6 років тому

    OMG you saved me! very useful!

  • @subs2meplease
    @subs2meplease 13 років тому

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

  • @ceciliaamoako9694
    @ceciliaamoako9694 5 років тому

    You are a lifesaver

  • @TheaDragonSpirit
    @TheaDragonSpirit 12 років тому

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

  • @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.

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

    fucking legend. my final now looks possible fucking life saver

  • @Kalydosos
    @Kalydosos 13 років тому

    Got the code to compile OK however, my version of the program won't work without the system("pause"); and return 0; within main(). The program flicks the results on screen so quickly you can't see the results without the two functions above does anyone have any answers?

  • @mohdad-fadhilmusa8394
    @mohdad-fadhilmusa8394 4 роки тому

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

  • @danbreland3444
    @danbreland3444 7 років тому

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

  • @thehacker8454
    @thehacker8454 6 років тому

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

  • @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 ?.

  • @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.

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

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

  • @axehai
    @axehai 11 років тому

    We can write int *theArray instead of int theArray[]. Right?

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

    how to find length of array when only array is passed into the function ?

  • @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) { ... }

  • @koukirippy
    @koukirippy 11 років тому

    So, I have typed everything exactly as he has but for whatever reason nothing comes up when I build and run it. It did the same thing for the previous video.

  • @johnwayne2700
    @johnwayne2700 9 років тому +21

    Making prototypes above the main function and then writing a code of that prototype is redundant action. You just can write the function above the function main and it will work perfectly without making a mess in code by typping additional lines.

    • @johnwayne2700
      @johnwayne2700 9 років тому +1

      I get it

    • @jrarmas321
      @jrarmas321 8 років тому +3

      Thats funny because i was thinking the same thing,
      Couldn't he have just put the other function above main and would have been good to go?

    • @johnwayne2700
      @johnwayne2700 8 років тому +18

      After 3 months I admit that making prototypes is even better. When you don't make prototypes you have to plan your code so that inner functions have to be above outer ones. By pointing out making prototypes compiler knows about existence inner functions so they don't have to be above the outer ones. Quite helpful, isn't it ?

    • @jrarmas321
      @jrarmas321 8 років тому

      yeah so its sorta like a comment in a way? helping you understand your code or remember it correct?

    • @johnwayne2700
      @johnwayne2700 8 років тому +1

      Not exactly. Commenting can be helpful, but has no effect on compiling. Declaring prototypes of your function tells the compiler that such function exists when is brought out without defining it above. This way compiler knows that there is no reason to panic since it reckons that if declaration was provided, definition will also be provided later.

  • @MherBedrossian
    @MherBedrossian 11 років тому

    what kind of a program he's using? doesn't look like visual studio to me, can anyone tell me please ?

  • @Dukekilo
    @Dukekilo 8 років тому +80

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

  • @herp_derpingson
    @herp_derpingson 12 років тому +2

    :O
    *Jaw Dropped*

  • @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?

  • @kraeukai
    @kraeukai 14 років тому

    do arrays in c++ have no length method?

  • @user-cf7vy4hl8p
    @user-cf7vy4hl8p 10 років тому

    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.

  • @Globox822
    @Globox822 11 років тому +1

    bad ass bucky, thx

  • @lobnahamdi4660
    @lobnahamdi4660 7 років тому

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

  • @quantumhm96
    @quantumhm96 12 років тому

    Bucky, How do you make return an array in a fucntion?

  • @CCNezin1
    @CCNezin1 14 років тому +1

    Why can't you just put the entire function before main? Is that bad practice?

  • @creativeknowledgemike2337
    @creativeknowledgemike2337 7 років тому

    in the loop where it says thearray[x] [x] signifies the int right? since it is a int variable?

  • @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."

  • @faiqariaz180
    @faiqariaz180 9 років тому

    how do we add two different arrays of same length and store the result in any other array

  • @Deeredman4
    @Deeredman4 11 років тому

    I'm pretty sure you can include the body of your function with your prototype, anyone know if there is a reason you shouldn't do this?

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

    how does the compiler know "sizeOfArray" is the size of the array tho

  • @alizawahry570
    @alizawahry570 11 років тому

    Not codeblocks Its Dev-C++ available on sourceforge he mentioned it in the 1st tutorial