Explaining Pointers Until I Go Insane

Sdílet
Vložit
  • čas přidán 19. 04. 2024
  • 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.
    Hello there! I've been wanting to talk about quirky pointers for a while. They make no sense sometimes.
    Music used in the video:
    - Sewer surfing: • TMNT 4 (SNES) Music: S...
    - Flower garden: • Yoshi's Island OST - F...
    - Vordt of the Boreal Valley: • Vordt of the Boreal Va...
    - Pizza Parlor: • Club Penguin - Pizza P...
    - Figure-8 Circuit: • Mario Kart DS Music - ...
    - Mii Channel Theme: • Nintendo Wii - Mii Cha...
    - The Cyber Sleuth: • The Cyber Sleuth - Dig...
    - Bad Bully: • Kizumonogatari II ost ...
    - Wii Sports - Title: • Wii Sports - Title (HQ)
    - Spark Mandrill: • Mega Man X OST - Spark...
    - Hope Ster: • Hope Ster - Digimon St...
    - Flame Mammoth: • Megaman X - Flame Mamm...
    - Alleycat Blues: • TMNT 4 (SNES) Music: A...
    - Listen!!: • K-ON! - Listen!! Instr...
    - Going Up: • TMNT 4 (SNES) Music: G...
    - Still, Move Forward: • Still, Move Forward! (...
    - Royal Knights: • Royal Knights - Digimo...
    - A Dish is Best Served Cold: • Tee Lopes - A Dish Bes...
    - ミカヅキBIGWAVE -Emotional Prism 感情的なプリズム: • ミカヅキBIGWAVE - Emotiona...
    This video was sponsored by Brilliant.
    #Mults
  • Zábava

Komentáře • 540

  • @MultsElMesco
    @MultsElMesco  Před 28 dny +67

    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 Před 25 dny +3

      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 Před 6 dny +1

      I recognize that digimon cybersleuth ost

  • @tuhkiscgibin6627
    @tuhkiscgibin6627 Před 27 dny +1332

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

    • @atomgutan8064
      @atomgutan8064 Před 25 dny +132

      lol exactly. this is extreme obfuscation

    • @tuhkiscgibin6627
      @tuhkiscgibin6627 Před 25 dny +74

      @@atomgutan8064Some Jia Tan shit

    • @atomgutan8064
      @atomgutan8064 Před 25 dny

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

    • @avoavoavo
      @avoavoavo Před 25 dny +31

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

    • @tosemusername
      @tosemusername Před 24 dny +16

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

  • @Spitfire720
    @Spitfire720 Před 27 dny +1018

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

    • @deltamico
      @deltamico Před 27 dny +29

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

    • @nodrance
      @nodrance Před 24 dny

      I point on her... Wait

    • @deleteddeleted1940
      @deleteddeleted1940 Před 21 dnem +3

      learn about references!

    • @jeremymcadams7743
      @jeremymcadams7743 Před 20 dny +7

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

    • @mux1c
      @mux1c Před 5 dny

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

  • @vulnoryx
    @vulnoryx Před 26 dny +459

    "say pointer again"
    "fuck you"

    • @user-qr4jf4tv2x
      @user-qr4jf4tv2x Před 20 dny +1

      is that rick and morty

    • @vulnoryx
      @vulnoryx Před 20 dny

      @@user-qr4jf4tv2x yes

    • @nexushare8105
      @nexushare8105 Před 7 dny +1

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

    • @vulnoryx
      @vulnoryx Před 7 dny

      @@user-qr4jf4tv2x indeed it is

    • @ThisIsAnAccount
      @ThisIsAnAccount Před 4 dny

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

  • @LizardGecko420
    @LizardGecko420 Před 23 dny +184

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

  • @Hallilo
    @Hallilo Před 27 dny +234

    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 Před 25 dny +2

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

  • @ry6554
    @ry6554 Před 26 dny +289

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

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz Před 25 dny +9

      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 Před 25 dny +30

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

    • @user-uf4rx5ih3v
      @user-uf4rx5ih3v Před 25 dny +9

      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 Před 25 dny

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

    • @pitri_hub
      @pitri_hub Před 25 dny +7

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

  • @eleinaedelweiss6215
    @eleinaedelweiss6215 Před 25 dny +146

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

  • @JoaoJGabriel
    @JoaoJGabriel Před 19 dny +47

    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 Před 7 dny +3

      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 Před 7 dny

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

    • @lightlezs7048
      @lightlezs7048 Před 3 dny +2

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

    • @JoaoJGabriel
      @JoaoJGabriel Před 2 dny +1

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

    • @JoaoJGabriel
      @JoaoJGabriel Před 2 dny +1

      @@lightlezs7048 better?

  • @moneteezee
    @moneteezee Před 27 dny +72

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

  • @marcsfeh
    @marcsfeh Před 27 dny +127

    C's syntax makes things excessively hard to parse, in other languages like C3 or more Pascal style languages (like Go and Odin) it's much more clear how these declarations compose

    • @Apis035
      @Apis035 Před 27 dny +14

      Odin makes me realize that C's syntax is absolute mess. Odin's syntax makes writing function pointer really easy to understand 👍

    • @user-sl6gn1ss8p
      @user-sl6gn1ss8p Před 27 dny +14

      It's a feature to sure you realize you're doing something bad : p

    • @Jutastre
      @Jutastre Před 25 dny +1

      I think the trick to parsing C declarations is to go from the inside (the name) out. Although you still have to know parser priority. Like the animation at 2:40, except it messes up the priority by looking at "int" before [20]

    • @Jutastre
      @Jutastre Před 25 dny +1

      The 4:40 example shows the inside out parsing even better. The 5:35 example seems more complicated because of the function signatures but those aren't as important to parse IME. You basically just copy that from the function in question. If you need to understand it better you just look at that function itself.

    • @user-sl6gn1ss8p
      @user-sl6gn1ss8p Před 25 dny

      @@Jutastre yeah, the parsing itself is pretty straightforward once you know how things associate and the relevant operator precedence.
      You start from the name and apply stuff to it from there - the result of doing this will generate something of the type on the left (the "return type" of the expression).
      Making sense of complicated definitions without naming the steps in the way is just hard by nature - C lets you expose yourself to that, but doesn't make you: you can always typedef things into reasonable steps if you'd like.

  • @dipereira0123
    @dipereira0123 Před 26 dny +43

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

  • @GL0RYS
    @GL0RYS Před 27 dny +107

    bro lost me before the ad break 💀

    • @kingpen5866
      @kingpen5866 Před 25 dny +7

      Bro really said bro 💀

    • @GL0RYS
      @GL0RYS Před 25 dny +4

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

    • @fodetraore6666
      @fodetraore6666 Před 25 dny

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

    • @VictorMartinez-vi7jx
      @VictorMartinez-vi7jx Před 22 dny +3

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

    • @GL0RYS
      @GL0RYS Před 21 dnem +1

      @@VictorMartinez-vi7jx bros making sense 🙏

  • @norude
    @norude Před 25 dny +50

    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 Před 25 dny +4

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

    • @norude
      @norude Před 25 dny +14

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

    • @shanesnover4048
      @shanesnover4048 Před 25 dny +2

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

    • @norude
      @norude Před 25 dny +5

      @@shanesnover4048 that's true, but not relevant

    • @jrstf
      @jrstf Před 25 dny +10

      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.

  • @codecat3406
    @codecat3406 Před 21 dnem +3

    The fact that C lets you write stuff like this makes me think that someone forgot to write it as an entry in the Geneva convention

  • @halflight8811
    @halflight8811 Před 27 dny +20

    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

  • @James-ne9td
    @James-ne9td Před 24 dny +46

    "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 Před 24 dny +15

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

    • @happygofishing
      @happygofishing Před 24 dny

      random swearing is peak reddit humour

    • @James-ne9td
      @James-ne9td Před 23 dny

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

    • @user-vt9bp2ei1w
      @user-vt9bp2ei1w Před 22 dny

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

    • @user-vt9bp2ei1w
      @user-vt9bp2ei1w Před 22 dny

      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.

  • @tvardero
    @tvardero Před 24 dny +4

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

    • @dawiddulian2403
      @dawiddulian2403 Před 2 dny

      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.

  • @norude
    @norude Před 25 dny +18

    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. Před 22 dny +1

      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 Před 3 dny

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

  • @jatinsharma3280
    @jatinsharma3280 Před 26 dny +7

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

  • @tiaanbasson9092
    @tiaanbasson9092 Před 27 dny +7

    That line of code in the thumbnail alone drove me insane and I haven't even watched the video yet.

  • @iCrimzon
    @iCrimzon Před 25 dny +7

    "Go insane?" GO MENTIONED RAAAAAAAAAAAAAAAAAAAAAAAAA

    • @batatanna
      @batatanna Před 25 dny

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

  • @prism223
    @prism223 Před 26 dny +14

    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.

  • @xtremecoding4005
    @xtremecoding4005 Před 27 dny +5

    This video made me cry

  • @zFede_Rico
    @zFede_Rico Před 26 dny +15

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

  • @NicolasChanCSY
    @NicolasChanCSY Před 26 dny +10

    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: 😱😱😱

  • @therealdia
    @therealdia Před 25 dny +5

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

  • @Diamondyoutubization
    @Diamondyoutubization Před 26 dny +3

    I think this video actually made these easier to parse.

  • @Rose-ec6he
    @Rose-ec6he Před 23 dny +1

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

  • @mvargasmoran
    @mvargasmoran Před 25 dny +2

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

  • @mrprongles9510
    @mrprongles9510 Před dnem

    What i learned from this video is that function pointers are pretty cool! :)

  • @josephmazor725
    @josephmazor725 Před 25 dny +3

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

  • @mazyyyy
    @mazyyyy Před 24 dny +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!

  • @bubbleopter
    @bubbleopter Před 23 dny +2

    Such an awesome teaching style!

  • @iagopaulo2445
    @iagopaulo2445 Před dnem

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

  • @user-hh8jh5gw8i
    @user-hh8jh5gw8i Před 24 dny

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

  • @arthyrgoldengate4599
    @arthyrgoldengate4599 Před 18 hodinami

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

  • @sdwone
    @sdwone Před 19 dny

    Understanding pointers, is like the Great Barrier between amateur devs and the pros! Because THIS is a concept in which knowing how computers actually works, helps tremendously!

  • @Muskar2
    @Muskar2 Před dnem

    A pointer consists of: 7, 9, 9, 9, 9, 9, 12.
    I.e. 7 bits unused, 12 bits for the physical offset in memory and the 9's are offsets into a page "tree" if you will . Most CPU's today only use four-level pages, so the top 16 bits (instead of 7) are unused - but Intel is starting to use five-level pages too. It's also why pages are 2^12 (4096) in size, and why large pages can be 2MB (2^(12+9)) and 1GB (2^(12+9+9)) respectively. You can cast a pointer to a number, and shift the bits into different values to clearly see how there's a clear pattern when you allocate memory etc.

  • @tosaksettharungson
    @tosaksettharungson Před 17 dny

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

  • @theimmux3034
    @theimmux3034 Před 25 dny +2

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

  • @hodayfa000h
    @hodayfa000h Před 26 dny +2

    My favorite programming channel

  • @drominitoketchup
    @drominitoketchup Před 27 dny +6

    I understood 80% after 15 min totally

  • @mothratheresa8582
    @mothratheresa8582 Před 2 dny

    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

  • @PBalint817
    @PBalint817 Před 6 dny

    This makes me thankful for the C# syntax

  • @landin1181
    @landin1181 Před 25 dny +4

    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.

  • @glitchy_weasel
    @glitchy_weasel Před 21 dnem

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

  • @vesale.a7745
    @vesale.a7745 Před 23 dny

    I seriously never could imagine insanity up to this level.

  • @ffreezed5620
    @ffreezed5620 Před 26 dny

    ohhh, i get it, thx :D. Finally understand pointer in my 3rd year in uni :)

  • @JacksHQ
    @JacksHQ Před 21 dnem

    You had me at "Fucker". Subscribed.

  • @proteinsheikh9544
    @proteinsheikh9544 Před 26 dny

    Absolute heater 🔥🔥🔥🔥

  • @bobedge289
    @bobedge289 Před 19 dny

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

  • @birdrun4246
    @birdrun4246 Před dnem

    I have been working professionally with C for well over a decade. I know most of the ways it can bite. If I see any of these in production, I'm burning the codebase and walking away, and so should you.

  • @craftydoeseverything9718
    @craftydoeseverything9718 Před 27 dny +3

    How did you not go insane sooner?!!?!?!???

  • @john.darksoul
    @john.darksoul Před 24 dny +8

    I REFUSE to understand this syntax.

  • @dimi144
    @dimi144 Před 8 dny

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

  • @pierrotarat
    @pierrotarat Před 25 dny +1

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

  • @mikaelluca8827
    @mikaelluca8827 Před 24 dny

    love the soundtrack

  • @farukyldrm8498
    @farukyldrm8498 Před 25 dny +1

    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

  • @MadMetalMacho
    @MadMetalMacho Před 24 dny

    Small clarification: you're never pointing to an array, you're always pointing to the location where your array starts.

  • @lovalmidas
    @lovalmidas Před 21 dnem

    On one hand, class/module structures and delegates are basically pointer stuff in pure C. In higher languages, these things 'look' much simpler, by simpler it means the context now spans several .cs files. :P
    On the other hand, your professor could give you a snippet of ASM code, and ask something like: provide an (or the most restrictive) equivalent C function signature of a CALL function in the code. Yes, you shall use "mov dh,word ptr [eax]" to figure out that eax is a pointer to the value dh now holds, and the only use case of the value being "test dh,dh" means eax can be a *byte, or *bool.
    :'D

  • @damindux
    @damindux Před 10 dny

    Now I'm seeing stars everywhere.

  • @semmu93
    @semmu93 Před 24 dny

    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

  • @ThousandsOfPk
    @ThousandsOfPk Před 23 dny

    Interfaces are a fine abstraction from function pointer madness

  • @satoshikei
    @satoshikei Před 24 dny +2

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

  • @yuritsukahara
    @yuritsukahara Před 24 dny +1

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

  • @AVYAY-md1vx
    @AVYAY-md1vx Před 24 dny +1

    As a veteran coder i can say that professionals store this kind of useless data because it becomes useful in a absolutely stupid situation. Just store this shit.

  • @drominitoketchup
    @drominitoketchup Před 27 dny

    Hi, you have been found in my recommendation :O
    I'm watching it only 0:32 and already subscribed you.
    You have a funny sense of Humor btw xD.

  • @keheck
    @keheck Před 7 dny

    There's probably already been someone saying this, but at 1:09, the allocation for the FUCKER variable was technically not correct, since alignment could see the struct end up larger than the raw data it contains. For instance, if we used an int after the char[6], most compilers would add a 2-byte padding before it to ensure that the address of the int is divisible by 4 (size of a 32 bit int which I assume is what int is)
    In general, the safest option is to always use malloc(sizeof()); it'll give you the correct size the compiler will assign your structs

  • @naveenwilliam3594
    @naveenwilliam3594 Před 21 hodinou

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

  • @Komil484
    @Komil484 Před 27 dny +2

    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

  • @klevisimeri607
    @klevisimeri607 Před 26 dny +1

    I like your vids a lot!

  • @aaravdayal4529
    @aaravdayal4529 Před 25 dny

    This actually made me understand pointer expressions. Thank you.

  • @VivekYadav-ds8oz
    @VivekYadav-ds8oz Před 25 dny +1

    I can't believe I actually was able to solve the last two after fumbling on all the previous ones (mainly because of parenthesis which changed if x was a pointer to an array or an array of pointers). I think I'm cursed now.

  • @psyk0oooo
    @psyk0oooo Před 27 dny +2

    i like your funny words magic man

  • @ChrisgammaDE
    @ChrisgammaDE Před dnem

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

  • @wiltonribeiro3951
    @wiltonribeiro3951 Před 2 dny

    Ok i need revisit some pointer videos before understand this

  • @madalenaferreira3018
    @madalenaferreira3018 Před 23 dny

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

  • @felix34ever1
    @felix34ever1 Před 11 dny

    Ngl i actually understand now thanks 🥰😂

  • @VictorMartinez-vi7jx
    @VictorMartinez-vi7jx Před 22 dny

    I am subscribing without further questions

  • @JLSXMK8
    @JLSXMK8 Před 26 dny

    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?

  • @JerryThings
    @JerryThings Před 21 dnem

    This video is amazing

  • @sasho_b.
    @sasho_b. Před 22 dny +1

    Is that the all-too-common array of arrays length 8 of pointers to functions returning pointer to array of pointers to char?
    (The order is name, sufix, prefix, and operators on a name before sufix brackets (i.e. function argumrents) infer that the function is what is being stored in that way, after that is what is being returned; this necessitates that the type before the sufix brackets be a pointer as anything else C wouldnt know how to store)
    (Also the question would not parse, let alone make sense, you declare an array of arrays of undefined length, thats not allowed, if it was itd be an array of arrays of pointer pointers to functions returning a pointer to arrays len 8 with pointers to int)
    Or, in simple terms, its probably a number.
    Tldr just use c++, rust, java, python, ets. C is for pointer tricks and programming elevators, not for actual use. Unless you're making an OS, then it may come of use. C walked so that higher level languages could run.

  • @ggibby0450
    @ggibby0450 Před 8 dny

    If I ever see a pointer to a pointer to a pointer or anything more nested than that, I'm deleting system32, quitting CS, and starting my career as a professional mind reader. Because taking a wild guess at whatever is going on inside someone's head would still be easier then desciphering some of this shit.

  • @joshuam2263
    @joshuam2263 Před 24 dny +1

    I came into this, expecting to learn how to read that stuff. Sadly I don't think I learned anything (except maybe reading the decl from the inside outwards?). This video was entertaining though. Just to give you feedback

  • @distorted_heavy
    @distorted_heavy Před 11 dny

    Ive personally written terrible code like this and iirc it looked like this:
    #define FUNCORDER (int (* [])(struct data *)){func1, func2, func3}
    It is a staticly defined, "anonymous" array of function pointers that accept a pointer to a struct I made & return ints. All of this to save 1 switch statement

  • @ZenWith
    @ZenWith Před 25 dny +1

    explaining GO pointers till i GO insane

  • @Herio7
    @Herio7 Před 14 dny

    The biggest problem with pointers is batshit insane C syntax.

  • @thfsilvab
    @thfsilvab Před 24 dny

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

  • @Wazzup_Taibei
    @Wazzup_Taibei Před 24 dny

    interviewer: Great, add it to our interview question list!

  • @Morgan_iv
    @Morgan_iv Před 16 dny

    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

  • @s8x.
    @s8x. Před 25 dny

    bro got every meme in his vault

  • @nickpratt9338
    @nickpratt9338 Před 25 dny

    Please do a vid of how you got that view of memory!

  • @pierregarric6674
    @pierregarric6674 Před 20 dny

    To create a program that parses a C expression and translate it into a sentence would be quite fun to do

  • @therelatableladka
    @therelatableladka Před 25 dny

    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 !!! ❤

  • @Pryvyd9
    @Pryvyd9 Před 24 dny

    This is cool but I like doing practical stuff with pointers. Like serializing objects as if they were binary arrays or creating smart pointers which delete themselves when nobody references them.

  • @DavidSchiess
    @DavidSchiess Před 22 dny

    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.

  • @Andres-fb8gm
    @Andres-fb8gm Před 6 dny

    “Explaining pointers until I go insane” yeah 6 minutes took u way longer than I expected

  • @lollogeimer351
    @lollogeimer351 Před 14 dny

    And this is just the declaration, imagine using those pointer

  • @Marvindao
    @Marvindao Před 24 dny

    yo! nice video! could i ask what mic do u use?