Explaining Pointers Until I Go Insane

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

КОМЕНТАРІ • 891

  • @MultsElMesco
    @MultsElMesco  8 місяців тому +127

    Hello everyone! I've been doing some mix and match with my content style lately. Just trying new things. Let me know what you think :)
    To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/Mults
    You’ll also get 20% off an annual premium subscription.

    • @mxblock
      @mxblock 8 місяців тому +5

      Not a regular viewer (yet), but -
      This right here is literally a master piece for me. Educational, something interesting, memes (not to in you'r face / loud audio - still prominent to be entertaining), relatability, the ever growing crazieness, straight to the point, not to short nor to long, right volume for music and mic, the outro song - all just perfect. Keep it up!

    • @NeostormXLMAX
      @NeostormXLMAX 7 місяців тому +2

      I recognize that digimon cybersleuth ost

    • @oioio-yb9dw
      @oioio-yb9dw 4 місяці тому

      You escaped pointer hell with that add 😅

    • @oioio-yb9dw
      @oioio-yb9dw 4 місяці тому

      Subscribed🫡

    • @XinTongXia-d2o
      @XinTongXia-d2o 4 місяці тому

      btw, anyone know what's font used in the video? looks pretty nice

  • @vulnoryx
    @vulnoryx 8 місяців тому +1433

    "say pointer again"
    "fuck you"

    • @user-qr4jf4tv2x
      @user-qr4jf4tv2x 7 місяців тому +5

      is that rick and morty

    • @vulnoryx
      @vulnoryx 7 місяців тому

      @@user-qr4jf4tv2x yes

    • @nexushare8105
      @nexushare8105 7 місяців тому +2

      damn how did i read it in rick and morty voice in my head 😆

    • @vulnoryx
      @vulnoryx 7 місяців тому

      @@user-qr4jf4tv2x indeed it is

    • @ThisIsAnAccount
      @ThisIsAnAccount 7 місяців тому

      Did you just... insult me with a **pointer**? Son of a..

  • @Suspaghetti
    @Suspaghetti 8 місяців тому +726

    You realize how complicated pointer syntax is when the best explanation of how to read complex statements is in a funny YT video

    • @Mr.Not_Sure
      @Mr.Not_Sure 7 місяців тому +14

      Well, nobody writes them in the first place. That's why `typedef` exists.

    • @garfield1964
      @garfield1964 5 місяців тому +5

      it's in a funny YT video because the concept--spiral rule--was documented before the youtuber was born and is prolific amongst anyone who has made efforts to properly understand C

    • @Suspaghetti
      @Suspaghetti 5 місяців тому +4

      @@garfield1964 Yes, definitely. It's just that most [modern] beginner C books and tutorials skip this, even though it's essential. I was actually introduced to the spiral rule by this video and it blows my mind how not widespread it is, given its simplicity.

  • @tuhkiscgibin6627
    @tuhkiscgibin6627 8 місяців тому +2874

    If a codebase has any of this stuff, you'll know it's been backdoored.

    • @atomgutan8064
      @atomgutan8064 8 місяців тому +283

      lol exactly. this is extreme obfuscation

    • @tuhkiscgibin6627
      @tuhkiscgibin6627 8 місяців тому +153

      @@atomgutan8064Some Jia Tan shit

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

      @@tuhkiscgibin6627 lmao this is the new backdoor reference now ig

    • @avoavoavo
      @avoavoavo 8 місяців тому +70

      Once committed, always committed. No explanation is needed. It works.

    • @tosemusername
      @tosemusername 8 місяців тому +51

      Well, the person who backdoored it understood it, so jokes on you :P

  • @Spitfire720
    @Spitfire720 8 місяців тому +2001

    Aight I'm never listening to the word "pointer" again

    • @deltamico
      @deltamico 8 місяців тому +41

      "pointer"
      You can read it instead. You're welcome

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

      I point on her... Wait

    • @deleteddeleted1940
      @deleteddeleted1940 7 місяців тому +5

      learn about references!

    • @jeremymcadams7743
      @jeremymcadams7743 7 місяців тому +10

      Let me give you a few pointers about how to get over this issue

    • @mux1c
      @mux1c 7 місяців тому +1

      I'd like your comment, but it's at 911 and I can't ruin that

  • @eleinaedelweiss6215
    @eleinaedelweiss6215 8 місяців тому +548

    Who the hell would write the last one, without questioning their lives decisions.

    • @etherstrip
      @etherstrip 7 місяців тому +18

      …people making youtube videos?

    • @Elias01056
      @Elias01056 7 місяців тому +5

      who the fuck would use *

    • @danilbutygin238
      @danilbutygin238 7 місяців тому +1

      @@Elias01056 i am

    • @Elias01056
      @Elias01056 7 місяців тому +2

      @@danilbutygin238 why?

    • @danilbutygin238
      @danilbutygin238 7 місяців тому +2

      @@Elias01056 long-term habit

  • @Hallilo
    @Hallilo 8 місяців тому +464

    I honestly never had any issues understanding basic and more advanced pointer stuff, but THIS is some actual good stuff LMAO great video

    • @ThisShitWontWor
      @ThisShitWontWor 8 місяців тому +9

      12 years old me learning C++ : "Ok so, its a box containing... a box, ok?, containing a box... fuck it"

    • @kaustubhsonar4613
      @kaustubhsonar4613 6 місяців тому +10

      Bring me that stuff which you are smoking

    • @user-sb5vt8iy5q
      @user-sb5vt8iy5q 2 місяці тому +1

      I got almost all of them in under 20 seconds, except the last one, I didn't even try to get it because at that point what are you doing

  • @ry6554
    @ry6554 8 місяців тому +606

    Honestly,
    An array of functions sounds pretty dope.
    Nevermind, an array of pointers to functions sounds pretty dope.

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 8 місяців тому +18

      ain't that the same? or are we saying "an array of pointers to function pointers" (effectively double-indirection) in the second one?

    • @theepicguy6575
      @theepicguy6575 8 місяців тому +56

      Well, you can't have arrays of functions in the first place
      Only pointers to functions

    • @PhthaloJohnson
      @PhthaloJohnson 8 місяців тому +16

      In C, you actually cannot store functions inside arrays anyway, the compiler will silently convert that code into a pointer to that function instead.

    • @jrstf
      @jrstf 8 місяців тому +3

      Is not every C++ member function referenced through an array of pointers to functions?

    • @pitri_hub
      @pitri_hub 8 місяців тому +12

      @@jrstf Per default, member functions are just statically compiled into the calling code. But it is true for virtual functions. They are referenced in the vtable, which exists for each type with virtual functions. Each of these objects then has an internal pointer to its respective vtable, which contains the pointers to the implementation defined procedures. This is how dynamic polymorphism is implemented.

  • @dipereira0123
    @dipereira0123 8 місяців тому +273

    to whoever reached a point in life where you ended up here or doing this, i really hope you find inner peace one day...

    • @kyumullo
      @kyumullo 7 місяців тому +34

      A Pointer in life

    • @CapeSkill
      @CapeSkill 7 місяців тому +6

      @@kyumullo ba dum tss.

  • @JoaoJGabriel
    @JoaoJGabriel 7 місяців тому +201

    It all can get stupidly complicated as we've seen, but the syntax follows simple rules:
    1. start reading from the identifier out
    2. favor [ ] and ( ) over *
    int (*(*x)[ ]) ( ):
    - Following rule #1, we start at x
    x
    - The identifier x is alone in parentheses with an asterisk, so it is [§1] a pointer
    *x
    - Outside of the parentheses, we follow rule #2, so it is [§2] an array
    (*x)[ ]
    - We're left with an asterisk inside the parentheses, so [§3] pointers
    *(*x)[ ]
    - Outside of the parentheses, rule #2, [§4] functions
    (*(*x)[ ])( )
    - The functions return [§5] int
    putting §1, §2, §3, §4 and §5 together:
    x is (§1) a pointer to (§2) an array of (§3) pointers to (§4) functions that return (§5) an integer
    Once you got the hang of it, you can rewrite the example like:
    * [ ] * ( ) -> int
    And stitch things together in a way that makes sense. "->" means "returns" and it's optional/redundant (anything immediately after parentheses in this notation is a return anyway)
    Take the example of 5:34:
    [ ] * * (* char, * (* char) -> * int) -> [ ] * (* * char, * ( ) -> * char) -> * int
    Array of pointers to a pointer to a function that takes (a pointer to a character and a pointer to a function that takes (a pointer to a character) and returns a pointer to an integer) and returns an array of pointers to a function that takes (a pointer to a pointer to a character and a pointer to a function that returns a pointer to a character) and returns a pointer to an integer
    It looks insane, but it's not that difficult to wrap your head around if you're writing it following those two simple rules

    • @nexushare8105
      @nexushare8105 7 місяців тому +23

      bro i was with you util i expanded ur explanation... after expanding it i sad( i aint reading all this sheet lol) , but hey, great that u can explain this

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

      @@nexushare8105 maybe there's a way to be more concise but then that's me who can't bother xD

    • @lightlezs7048
      @lightlezs7048 7 місяців тому +10

      My man, using asterisks here for anything but pointers is fucking evil, was there really no other way?

    • @JoaoJGabriel
      @JoaoJGabriel 7 місяців тому +2

      @@lightlezs7048 hahahaha good point, I'm gonna change that

    • @JoaoJGabriel
      @JoaoJGabriel 7 місяців тому +1

      @@lightlezs7048 better?

  • @BaneDestabapillado
    @BaneDestabapillado 6 місяців тому +18

    Small tip for 1:20, you can order malloc like you did just by manually asking for each memory "sizeof(char) * 6..." but if you make a tipedef of your struct, you can just ask for a "sizeof(FUCKER)" and it will do the same, but far easier to read, and simpler

  • @moneteezee
    @moneteezee 8 місяців тому +97

    im actually glad i found this video, you explained this well and now i know how to interpret those long lines

  • @NicolasChanCSY
    @NicolasChanCSY 8 місяців тому +51

    A programmer goes to therapy.
    Therapist: Please tell me what you are scared of.
    Programmer: I am scared of pointers.
    Therapist: Okay, let me give you an array of pointers to handle them.
    Programmer: 😱😱😱

    • @SwiftyTheSword94
      @SwiftyTheSword94 Місяць тому +4

      The worst part is the therapist passes by reference.

  • @no-ld3hz
    @no-ld3hz 6 місяців тому +8

    3:24 funnily enough this is how dynamic dispatch works in c++, each class (implicitly) creates a pointer to a global array of function pointers. This is also known as a virtual table or vtable/vftable as it contains the list of "virtual" functions for that class.

  • @halflight8811
    @halflight8811 8 місяців тому +38

    this is what I understood from 3:10
    - arr[0] -> func1 => int1
    - arr [1] -> func2 => int2
    x ->arr - arr[2] -> func3 => int3
    - arr[3] -> func4 => int4
    - arr[4] -> func5 => int5

    • @teerathagarwal9352
      @teerathagarwal9352 Місяць тому

      Seems correct. However, getting to return the integer by calling those functions seems a different story. I guess it be something like this:
      (*x)[2]();

  • @jatinsharma3280
    @jatinsharma3280 8 місяців тому +19

    Man, It felt awesome and confusing at the same time, but thanks to you I come to know the different use of pointers.

    • @poleve5409
      @poleve5409 4 місяці тому +1

      function pointers are cool. But everything after it? only for the insane.

  • @tvardero
    @tvardero 8 місяців тому +22

    6:00 Bro is holding the entire class inside his variable definition
    The God Variable.

    • @dawiddulian2403
      @dawiddulian2403 7 місяців тому +1

      A class that someone parameterised the hell out of, it's like "okay, let x point to containers upon containers of functions (class) that parse strings... but in a waythat is so parametrised and specific that you need to parse other string in your chosen function and based on result of parsing you get the answer of your call of x...
      ...the anser being a f***ing array ofpointers to functions! So basically the class that is x is not all - you now use this class to hold the answers of called(/callable) functions and use THEM as your ACTUAL functions that themselves take an array of strings and parse those strings collection based on (presumably, because it doesn't make much sense otherwise) the original character that is returned from chosen constexpr function (due to no parameters)...
      ...and all that returns an adress of where the value of it is stored, YOU KNOW, LIKE IT'S TOTALLY NORMAL.

  • @finmat95
    @finmat95 5 місяців тому +2

    00:07 "So what is this?" "Obviously A NIGHTMARE."

  • @mysterry2000
    @mysterry2000 6 місяців тому +2

    This video is amazing, now I can play that game with my friends:
    Team A: Take a shot every time he doesn't say "pointer"
    Team B: Take 3 shots every two times he says "pointer"
    Let's see who wins 💪

  • @norude
    @norude 8 місяців тому +69

    I think, most of the confusion comes from the syntax.
    For example, int (*(*x)[])()
    in Rust, would be Box>
    "Box" is Rust's pointer
    i32 is Rust's int

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

      If I understood it correctly, that's a pointer to a vector of pointers to functions that return an int, right?

    • @norude
      @norude 8 місяців тому +19

      yes, it's just a lot of angle brackets, in a way that actually makes sense
      C works the other way around

    • @shanesnover4048
      @shanesnover4048 8 місяців тому +3

      Your outermost Box is unnecessary indirection as the Vec already places the memory on the heap.

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

      @@shanesnover4048 that's true, but not relevant

    • @jrstf
      @jrstf 8 місяців тому +18

      Imagine programming in a language where you can actually specify the type of a value (i32) rather than some kind of a suggestion which varies in meaning in every implementation and even with platform specific switches on the command line.

  • @GL0RYS
    @GL0RYS 8 місяців тому +184

    bro lost me before the ad break 💀

    • @kingpen5866
      @kingpen5866 8 місяців тому +10

      Bro really said bro 💀

    • @GL0RYS
      @GL0RYS 8 місяців тому +9

      @@kingpen5866 bro really said bro cause i said bro 💀

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

      Bro realy saic bro to some bro who realy said bro to bro 's comment 💀​@@GL0RYS

    • @VictorMartinez-vi7jx
      @VictorMartinez-vi7jx 7 місяців тому +20

      bro is a pointer to a bro that points to a bro

    • @GL0RYS
      @GL0RYS 7 місяців тому +2

      @@VictorMartinez-vi7jx bros making sense 🙏

  • @ANTI_UTTP_FOR_REAL
    @ANTI_UTTP_FOR_REAL 4 місяці тому +3

    "Did you explain them?"
    "Yes"
    "What did it cost you?"
    "Everything"

  • @iCrimzon
    @iCrimzon 8 місяців тому +22

    "Go insane?" GO MENTIONED RAAAAAAAAAAAAAAAAAAAAAAAAA

    • @batatanna
      @batatanna 8 місяців тому +2

      WE GOIN OUT OF THE HOOD WITH THIS ONE 🗣️🗣️🗣️🗣️🗣️

    • @gruberu
      @gruberu 5 місяців тому +1

      sanest go programmer

  • @aberryth_dev
    @aberryth_dev 8 місяців тому +6

    I don't understand, at 6:09, if the array of pointers to functions receive a pointer to a pointer of characters, where do I find the point of living?

    • @MartinDerTolle
      @MartinDerTolle 8 місяців тому +4

      Maybe we lost the point of life somewhere along the way

  • @bubbleopter
    @bubbleopter 8 місяців тому +4

    Such an awesome teaching style!

  • @Sky-The-Second
    @Sky-The-Second 5 місяців тому +2

    Bro I sat here with a notebook trying to understand, which I did pretty easily. Excellent explanation for such a troll video!

  • @Eliask-rv1wq
    @Eliask-rv1wq Місяць тому

    thank you I was confused by pointers and wasn't sure I should get back to trying to learn C but your video made me stop questioning myself and convinced me to abandon the idea of getting back to it for good. like

  • @josephmazor725
    @josephmazor725 8 місяців тому +7

    Actually the best explanation of these bullshit functions I’ve seen, thanks!

  • @adnanrasheed4366
    @adnanrasheed4366 5 місяців тому +5

    I've forgotten my name after learning about pointers from him. This person went insane before completing pointer😄

  • @Sea_Otter
    @Sea_Otter 6 місяців тому

    I gave this video a thumbs up even before watching it. Anyone who tries to explain pointers to us 'dumbdumbs' is definitely a modern-day Prometheus.

  • @kostabelov6376
    @kostabelov6376 2 місяці тому +3

    6:18 I too like words LMAO

  • @James-ne9td
    @James-ne9td 8 місяців тому +86

    "For example, if I use this struct 'Fucker'" caught me completely off guard XD
    My main takeaway from this video though is that as a C# dev for Unity, I shouldn't touch C++ with a 5 foot pole or else risk entering pointer hell.

    • @vibaj16
      @vibaj16 8 місяців тому +28

      no one actually uses crazy pointer stuff like this. Actually useful pointer stuff is simple and often feels quite elegant.

    • @happygofishing
      @happygofishing 8 місяців тому +3

      random swearing is peak reddit humour

    • @James-ne9td
      @James-ne9td 8 місяців тому +2

      @@vibaj16 tbf, I was being slightly hyperbolic. I do want to get round to learning C++ eventually but the combination of pointers, header files, garbage collection, and syntax is just a lot.

    • @Jason-b9t
      @Jason-b9t 7 місяців тому

      @@vibaj16 It's really simple.... The library will only use (void* buf, size_t n) for ALL types. C believes that smart users know that the void* returned by the function is a specific type among the 100+ custom types, it will be a linklist + table with a specific internal mix of pointers to stack and pointers to allocated heap, and then you have to be careful about pointer casts, linklist iteration, use void* to calculate offsets, of course you will remember which one is CHAR8* string and which is CHAR16* string, finally free the heap allocation and perfectly avoid the pointer to the stack.
      The biggest advantage of C is that it is suitable for keeping your job.

    • @Jason-b9t
      @Jason-b9t 7 місяців тому

      It's really simple.... The library will only use (void* buf, size_t n) for ALL custom types. It is linklist + table with a specific internal mix of pointers to stack and pointers to allocated heap, CHAR8* string and which is CHAR16* string.

  • @PackPosse
    @PackPosse 6 місяців тому +1

    As hairy and convoluted as the examples got, you did a fantastic job of breaking them down. I’ve spent most of my time coding in python and Java, so have thankfully never had to use pointers in practice. I do, however, remember the outright confusion experienced during a college C++ class…

  • @norude
    @norude 8 місяців тому +25

    I finally understood. The type signatures are provided not the obvious way around, but outside in.
    For example:
    int x()
    is a function named "x", returning an integer. But instead of "x", I can put something different and it will mean, put the whole function inside whatever is in that position. For example "int (*x)()" means to put the function inside the *x. So It's a pointer to a function.
    But it's not just functions, it's **everything**
    if we analyze the "int (*x)()" again we get:
    int , which means to put the integer inside something
    that something:
    ()
    It's a function! which means, that we put our int iside the return paramater of that function
    what's something:
    *
    it's a pointer! which means, we put our whole function with integer return type into a pointer.
    that something:
    x
    It's a name "x" which means, we put our whole pointer to a function with a return type of integer into the name "x"
    Let's do another example:
    char *(*(*(**x[])())[])();
    it's a char, which is in a pointer, which is in the return type of a function, which is in a pointer which is in an array which is in a pointer, which is in the return type of a function, which is in a pointer, which is in a pointer, which is in an array, which is in "x"

    • @sasho_b.
      @sasho_b. 7 місяців тому +2

      Nah
      I mean if you understand it then great, but nah
      Its name first, then sufix left-to-right, then prefix right-to-left, with () being the sufix function arguments operator. I best understand it same as the compiler, start from the inside and go out, sufix prefix exit-braket. Its doesnt matter here, yes, but this also reminds you how other operators work like array access and dereference operators. *x[8] means "take the 8th member of x and dereference", where as (*x)[8] means "dereference x and take the 8th member of that"

    • @ahmadalzibary4337
      @ahmadalzibary4337 7 місяців тому

      my honest reaction to this is: what the f$@% is that ?!?

  • @ZehllFierranDayJael
    @ZehllFierranDayJael 8 місяців тому +1

    Entertaining and very educational for me. Seeing different uses of pointers that you tried to demonstrate and describe them made my me intrigue, but at the same time dizzy. 😂

  • @amogussusmogus1
    @amogussusmogus1 3 місяці тому +1

    Thanks for the colors that help in pointing what you're pointing at so that your point can go straight to the point of my eyes and gets deleted any way which I point out that there's no point in this. There are some qwerty typists out there who like to type the word "point".

  • @roryb.bellows8617
    @roryb.bellows8617 5 місяців тому

    You know what's funny, I've been programming in C for 15 years and I was confused at he first one. But after you broke it down I understood it perfectly. I could even see situations where it would be quite useful to know. Great video, hope you're enjoying learning computer science. I still am

  • @mazyyyy
    @mazyyyy 8 місяців тому +2

    I FINALLY GOT POINTERS after more than 15 tutorials and another 15 "explanation" videos, you somehow made my brain click. Thank you so much!

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

    I think that this is 100% the reason for the existence of the typedef keyword

  • @kraqur
    @kraqur 6 місяців тому +3

    5:31 and at this point I soundly fell asleep and had a very restful night in dreamland, not worrying about pointers to pointers or functions calling pointers or anything returning an int again...

  • @mvargasmoran
    @mvargasmoran 8 місяців тому +3

    what I get from this is that the song at the end rocks.

  • @quocanhhbui8271
    @quocanhhbui8271 7 місяців тому +2

    Im watching this at 3:00am and yeah my brain is pretty much fried at this point

  • @arthyrgoldengate4599
    @arthyrgoldengate4599 7 місяців тому +1

    Came to learn about pointers, returned with all my braincells drained. 10/10

  • @therealdia
    @therealdia 8 місяців тому +7

    Ok how was this convoluted mess the thing that actually taught me how pointers work lol

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

    This video made me cry

  • @mothratheresa8582
    @mothratheresa8582 7 місяців тому +1

    1. Love the suffering
    2. Love the use of digimon story cyber sleuth ost, its suitable considering the BS that is the digivolution tree.
    3. Great video

  • @zFede_Rico
    @zFede_Rico 8 місяців тому +19

    0:14 as soon as i read "france" i subscribed and liked the video

  • @madalenaferreira3018
    @madalenaferreira3018 8 місяців тому +1

    somehow this made me understand pointers better than 4 years in uni

  • @Diamondyoutubization
    @Diamondyoutubization 8 місяців тому +3

    I think this video actually made these easier to parse.

  • @prism223
    @prism223 8 місяців тому +21

    In older computers, especially Lisp machines, pointers always came with a size. A pointer was a 2-D object to the hardware. It had a location, and a size. The weirdness of C/C++ pointer types is an attempt to recapture some of the elegance of earlier hardware in a later era where the hardware forgot about data safety.

    • @mage3690
      @mage3690 5 місяців тому +2

      Location + size pointers are referred to as "wide pointers" in modern C++, AFAIK. You're right though -- C's syntax is a desperate attempt to make the size portion of a wide pointer into a compile-time issue rather than a run-time issue, mostly for performance reasons.

  • @atharv-naik
    @atharv-naik 4 місяці тому +2

    Wow! Now I can send this to my prof

  • @love-thugger
    @love-thugger 8 місяців тому +9

    Your memory view and c debugger in vscode look very nice. Could you do a video on how you set this up or just gimme some info lol im jealous.

  • @JacksHQ
    @JacksHQ 7 місяців тому +1

    You had me at "Fucker". Subscribed.

  • @hodayfa000h
    @hodayfa000h 8 місяців тому +2

    My favorite programming channel

  • @tommasopattaro1329
    @tommasopattaro1329 5 місяців тому +1

    I lasted 2 minutes, then my brain exploded, and i am a programmer...

  • @SasukeUchiha-uy9lf
    @SasukeUchiha-uy9lf 2 місяці тому

    The only time my brain relaxed was watching that ad in this video

  • @Franciscocao
    @Franciscocao 6 місяців тому +1

    An array of function pointers sounds like something that could be extremely useful,
    but I can't imagine any situation where it would be useful

    • @chri-k
      @chri-k 5 місяців тому

      You can find them all over the place in object oriented code

  • @thfsilvab
    @thfsilvab 8 місяців тому +1

    Even the parser gave up, and he's still going

  • @maxjiang1324
    @maxjiang1324 Місяць тому

    "am not going to double check that" - thanks God you are are still human😂

  • @pierrotarat
    @pierrotarat 8 місяців тому +1

    "Great, you've explained these quite well. Now use them."

  • @Komil484
    @Komil484 8 місяців тому +3

    The way i look at it is, the way you declare a pointer, is the way you access it. So if you got int *(*p[]), you'd access the innermost value (being the int) in the same way: *(*p[i]). And then you work your way backwards
    To make the point(er) clearer ill go through this. So you access the int by doing *(*p[]), so *p[] is an array of pointers to int, and *p points to an array of pointers to int, and p is a pointer to an array of pointers to int

    • @nexushare8105
      @nexushare8105 7 місяців тому

      anddd.... u just had to make this pun

  • @dbf8014
    @dbf8014 2 місяці тому +1

    LOOLL MARIO KART BGM it takes me back

  • @farukyldrm8498
    @farukyldrm8498 8 місяців тому +2

    you shoud have mentioned operator precedence.
    and also thr syntax related to those concepts perfectly fit into english grammar. as a Türk, ı can say it in english (up to some point) but cannot think of its meaning because we build up the noun phrases other way around

  • @watchingwolf8092
    @watchingwolf8092 7 місяців тому +3

    6:29 in which situation you may use it ?

    • @_RG99_
      @_RG99_ 2 місяці тому +1

      Hopefully never

    • @Maya4K
      @Maya4K 2 місяці тому +2

      Well, obviously when you need an array of pointers to pointers to functions that receive "a pointer to a character; and a pointer to a function that receives a pointer to a character and returns a pointer to an int" and returns a pointer to an array of pointers to functions that receive "a pointer to a pointer of characters, and a pointer to a function that returns a pointer to a character" as arguments, and return a pointer to an integer

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

      ​@@Maya4Kand when may you need that?

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

      @@apurbosarker112 lol never or at 1/10e1000 of the time @Maya4K just copy and paste the code explainations writen in the video

  • @montegus
    @montegus 8 місяців тому +3

    Hey, i'm learning by myself, how did you make your vscode like that? 0:56

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

      He is using the debugging features. Install the c extensions on vscode and look about how to use gdb debugging. Its a bit of a rabbit hole depending on the project.

  • @ChungusTheLarge
    @ChungusTheLarge Місяць тому

    Me: HOW ARE YOU FREEING ALL OF THIS
    The Heap: Freeing? YOU THINK THIS IS GETTING FREED?

  • @ryangrogan6839
    @ryangrogan6839 5 місяців тому +1

    Im not even going to lie. This video did more for me than any amount of researching and googling. Believe it or not, i actually learned how to read pointer syntax from this cluster fuck of a video.

  • @jean-kiara
    @jean-kiara 7 місяців тому +1

    Those complex function declarations make me think of complex relational database.

  • @ChrisgammaDE
    @ChrisgammaDE 7 місяців тому

    1:10 I'm pretty sure you can also use sizeof() directly instead of calculating manually

  • @iagopaulo2445
    @iagopaulo2445 7 місяців тому

    Omg I never understood pointers so well as I do right now thanks to this video

  • @DavidSchiess
    @DavidSchiess 7 місяців тому +1

    Why: If you're a postman in a small town and they ask you to "deliver this package to that weird yellow house", you'll figure out where to deliver what in a reasonable amount of time. But if you need to deliver a massive amount of packages, that are all stored in different places inside a big warehouse, to a couple of skyscrapers with multiple delivery points per floor, you'll have a much easier time if the exact address is provided.

  • @aperson1234-t8x
    @aperson1234-t8x 6 місяців тому

    Thanks for the pointers!

  • @Morgan_iv
    @Morgan_iv 7 місяців тому +1

    At some POINT I've stopped perceive word "pointer" as some meaningful entity and instead started to interpret it as some weird IKEA furniture name

  • @CourierSix01
    @CourierSix01 4 місяці тому

    The person who loves pointers, this video is to make him hate pointers
    Thank you. Now I'll send this to my friend 😂

  • @theimmux3034
    @theimmux3034 8 місяців тому +2

    "getting into programming is easy"
    the programming in question:

  • @drominitoketchup
    @drominitoketchup 8 місяців тому +6

    I understood 80% after 15 min totally

  • @codingmickey
    @codingmickey 4 місяці тому

    THANKS To YOU now my BRAIN is working *totally* properly

  • @therelatableladka
    @therelatableladka 8 місяців тому +1

    Everytime I paused and I am shocked how i get it before you start telling how to understand it. Maybe because i have been doing reverse engineering and malware stuff for long time now. Those codes actually have hell of typecasting with different data types and sizes. But greater video !!! ❤

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

    3:29 --> See line 15 (3:21) for further clarification.
    In short, line 25 is saying that you want to first dereference the pointer, followed by selecting the function at index 0 for that pointer; then you have to de-reference that index (the array itself decays to a pointer containing the addresses of each function) in order to call the function you want from that double pointer. i.e., createFunctionPointerArray() returns "& -> {&add, &subtract}". You're making an embedded function library, I guess you could say, that the variable references, and you have to dereference all those pointers to access the function you want. Easy to understand?

  • @Quarkee
    @Quarkee Місяць тому

    ...how the fuc did this actually help me understand pointers.
    For some reason I've been reading c++ order of operations(programming has a word for it i dunno it's 3am) from left to right thinking whatever is on the leftmost side (so often a basic type declaration like void, int e.t.c) was the first important thing and ive just been subconsciously remembering to prioritise asteriskt and parenthesis for, who knows why reasons, but if you just loop out from the variable/object/parameter/satan/x, remembering to prioritise the right side (functions or arrays(/square-brackets) before the left side, normal parenthesis firstforemost, then it goes in a back and forth in a repeatable pattern.
    I will guarantee you that I'll have forgotten this by tomorrow when I wake up but cool video man. 10/10 would "asmr to study to" again

  • @vayr880
    @vayr880 6 місяців тому

    im new to the concept of pointers and memory allocation, since i just started learning c++ a few days ago. decided to spend an hour or so looking at this after learning the basics of pointers until i feel like i understood enough about how it all ties together, i guess i learned more about it but now i have a painful headache...

  • @john.darksoul
    @john.darksoul 8 місяців тому +79

    I REFUSE to understand this syntax.

  • @Rose-ec6he
    @Rose-ec6he 7 місяців тому +1

    I wish this was a joke of some kind, then I wouldn't want to cry

  • @felix34ever1
    @felix34ever1 7 місяців тому +1

    Ngl i actually understand now thanks 🥰😂

  • @СашаЕгоров-п1ъ
    @СашаЕгоров-п1ъ 5 місяців тому +1

    That is NOT just a pointers... THAT'S A TORTURE TOOL!

  • @Feal-flf
    @Feal-flf Місяць тому

    This video made me understand pointers

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

    also all this pointer magic can be neatly swept under the rug if you use a lot of typedefs with proper names, makes the code much easier to understand for everyone

  • @Elias01056
    @Elias01056 7 місяців тому +30

    i'm going to throw up

  • @Herio7
    @Herio7 7 місяців тому +1

    The biggest problem with pointers is batshit insane C syntax.

  • @Pearforce
    @Pearforce 5 місяців тому +2

    Ive always been critical of the “auto” type being added to c++, but now im starting to see a valid use case…

  • @yuritsukahara
    @yuritsukahara 8 місяців тому +1

    awesome. dude I need your fonr and vscode thee right now

  • @uuu12343
    @uuu12343 Місяць тому

    Pointers are like your fingers, fingers that are pointing at something (aliased "x"), that object "x" is stored in an area known as the memory address
    A pointer holds the memory address containing variable "x"
    To obtain the value located in the memory address of variable x pointed by the pointer, use `&ptr`
    Now, a pointer to a pointer holds the memory address containing the original pointer object pointing to variable "x" above
    Repeat to keep getting the memory address of everything the previous level is pointing

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

    I'm having PTSD from university every time you say pointers more than 2 times in a row

  • @glitchy_weasel
    @glitchy_weasel 7 місяців тому

    Unirocanically very useful video.
    Mad respect at the dinosaurs who invented C lol

  • @satoshikei
    @satoshikei 8 місяців тому +2

    Pro Tip: Just add another */& or put around parentheses until you get no compilation errors.

  • @naveenwilliam3594
    @naveenwilliam3594 7 місяців тому

    Idk what the fuck happened to me but i was laughing like a fucking psycho everytime i hear the fucking word POINTER.

  • @tosaksettharungson
    @tosaksettharungson 7 місяців тому

    I buried this nightmare 20 yrs ago. After watching I'm sure I'll get one tonight.

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

    *Lecturer:* _"What is a char * ( *( * ( * * x [ ] )() ) [ ] ) (); ?"_
    *Me:* _"Can you use it in a snippet?"_
    *Lecturer:*

  • @M-MahdiHeydari
    @M-MahdiHeydari 6 місяців тому +1

    Stack overflowed! 😬

  • @LonelyK1d
    @LonelyK1d 5 місяців тому +1

    Honestly, i blame myself for clicking on the video , i wanna be the man i was 6 minutes ago... Fcuk this shit , im out ...😂