C Pointers in 3 MINUTES

Поделиться
HTML-код
  • Опубликовано: 4 фев 2025

Комментарии • 61

  • @rubynaxela8524
    @rubynaxela8524 20 дней назад +18

    I think one of the problems with learning about pointers is the fact that many people declare them in this "int *ptr" style. And by "many" I mean "most", unfortunately. This style makes you think "What's so special about this int variable? Why is there a star attached to its name? It's so random and confusing!". This also clashes with the dereference operator, where you also have to put an asterisk in front of the name. The same syntactic structure for two completely different things! Once I learned the pointers myself, I immediately started declaring them in the "int* ptr" style. This makes so much more sense. You can clearly see that "int*" is just a data type like any other and not some arcane magic int that behaves completely differently. The same goes for C++'s reference types.
    And yes, I'm well aware that declaring multiple pointer variables in one statement is problematic with this approach, because you have to put an asterisk in front of each name anyway, otherwise the unpreceded ones will just be variables of the base type, but I blame the design of C for that, and there's nothing we can do about it. You can declare each pointer in a new line if you like. Personally, I do it like this: "int* x, * y, * z".
    (yes, I'm using a weird * symbol, to prevent RUclips from bolding my text)

    • @thedoubleeguy
      @thedoubleeguy  20 дней назад +2

      There are a lot of small details in the C language that can be totally convoluted. I agree with your approach, and I get where you're coming from

    • @delq
      @delq 17 дней назад +1

      you are totally right, int* and int are separate types to begin with and i have always wondered why people put the asterisk on the variable name, i guess it allows them to know that it is a pointer to a another variable type but they should really just use a craftier name that highlights that information in the naming itself.

  • @iCrimzon
    @iCrimzon 18 дней назад +29

    This is not for Gen Z, let me do it in fortnite terms, think of 1, 2, 3, 4, 5 as memory address, if you get the chug jug and put it in 1, then by pressing your 1 key, youre retrieving the value of memory address 1 which is the chug jug

    • @GameDevGeeks
      @GameDevGeeks 16 дней назад +2

      I'm gen z and never played or watched fortnite, no hate to those who do it's just not my thing (I think the art style is ugly).

    • @JorgePires7-7-7
      @JorgePires7-7-7 16 дней назад +1

      ​@@GameDevGeeksrelax bro no one is judging you lol

    • @west_prime
      @west_prime 14 дней назад

      ​@@JorgePires7-7-7 no one is chug-jugging you 😅

    • @AmyLoidDisease
      @AmyLoidDisease 10 дней назад

      on skibidi that was a dub slime

  • @baracapy-q9l
    @baracapy-q9l 23 дня назад +39

    Please talk about recursion, variadic function, linked list ...

    • @x-zotic_minded
      @x-zotic_minded 22 дня назад

      Variadic functions? Like those: myprintf(const char *str, ...); kinda thing?
      That's a must have on this channel

  • @UsernameDoesntCare
    @UsernameDoesntCare 21 день назад +42

    Bruh this aint for Gen Z, a minute is unbearable, I could be playing Fortnite right now or doomscrolling 💀

    • @thedoubleeguy
      @thedoubleeguy  21 день назад +3

      This had me cracking up😅

    • @katarsisAX
      @katarsisAX 17 дней назад +1

      People exaggerate it so much. Its easy

  • @mcswizz9609
    @mcswizz9609 13 дней назад +1

    Dang this was such a clean explanation 🙏🔥

  • @DerekitoCorpcito
    @DerekitoCorpcito 15 дней назад

    Para las personas que no hablan Inglés se entiende! Gracias bro

    • @thedoubleeguy
      @thedoubleeguy  15 дней назад +1

      @@DerekitoCorpcito me alegra compa, fíjate hablo español y tal vez hago una seria pa mis amigos latinos

  • @angelozilian7359
    @angelozilian7359 23 дня назад +47

    "for Gen Z" 😅

  • @rodcosta290
    @rodcosta290 13 дней назад

    this is great, i dont even need to learn this, but it was quick so i couldnt miss this haha.
    thank you, now i can reverse engineer gtavi 🗿

  • @lucidwavez6346
    @lucidwavez6346 14 дней назад +2

    We need the subway surfers gameplay 😂

  • @hi_arav
    @hi_arav День назад

    Excellent video! Keep it up ^_^

  • @taufiqurrahmansagafkelrey2833
    @taufiqurrahmansagafkelrey2833 18 дней назад +2

    the "for genz" bought me

  • @5DPixel
    @5DPixel 13 дней назад

    Already knew this but just clicked on it because why not, can you do qwords and dwords

  • @PMWoahE
    @PMWoahE 16 дней назад

    Understandable, thanks

  • @VideosViraisVirais-dc7nx
    @VideosViraisVirais-dc7nx 16 дней назад

    Hmm
    // declaration
    String place = "HOUSE";
    int *ptr = &place;
    // Output
    println("%d*, ptr);
    // Glossary
    int = data type
    name, ptr = identifiers
    * = pointer symbol
    & = get address value of variable
    %d = specifier format

  • @IvanRodriguez-vu8yv
    @IvanRodriguez-vu8yv 16 дней назад

    When used in a declaration, the * symbol is not an operator at all. It doesn’t “act on” anything.

  • @amazingcaio4803
    @amazingcaio4803 14 дней назад

    FYI, 'A' is an int, not a char in C (yeah, it's confusing).

  • @robbiek5oh
    @robbiek5oh 20 дней назад +5

    its more helpful to explain the benefits of pointers (aka the "why") before explaining how to use them.....

    • @ismotheis
      @ismotheis 20 дней назад

      Yeah, and perhaps even, maybe especially the dangers of misusing them.

    • @rubynaxela8524
      @rubynaxela8524 19 дней назад +1

      Imagine you have an object (let's take a classic and overused example: a "person" struct). Now, imagine you also have two functions in your code, that both accept a "person" struct as an argument: one for displaying the person's full name & age, and another for asking the user to type those details and modifying the struct.
      Now, the important thing here is that both functions will receive a copy of the person's data. So, the first function will work perfectly fine, but the second one will only modify its own copy of the data (received as the argument), but not the original source.
      When you pass a pointer to the modifying function though, you tell it exactly where your original "person" struct is, allowing it to change it directly.

  • @baracapy-q9l
    @baracapy-q9l 23 дня назад +1

    First ❤️ keep going

  • @AudisioOficiaI
    @AudisioOficiaI 22 дня назад +1

    pointers is just to not copy a variable and change it value from a function

    • @NerdZEY
      @NerdZEY 18 дней назад

      From anywhere acctually

  • @closeen8574
    @closeen8574 20 дней назад +3

    what about double pointers?

  • @OceJlot
    @OceJlot 18 дней назад

    Actually, pointers are pretty easy, but I got confused once when I was working with an array and tried to get its sizeof. Then I passed it to a function (so into another scope), and when I got its sizeof there, it was already equal to the size of a pointer instead of the size of the array. This is because your array is actually just a pointer to its first element.
    Why was it working correctly in the main scope then? Compiler black-box magic 😅

    • @dawae5447
      @dawae5447 18 дней назад +1

      When you declare an array, you set a size for it, so its scope knows its size. When you pass it to a function, the function only receives a pointer, and no information of the memory it has reserved

    • @OceJlot
      @OceJlot 18 дней назад

      ​@@dawae5447 It's not actually the scope that knows the actual size. It's the compiler that replaces sizeof with this value at compile time. Correct me if I'm wrong

  • @mister_calm
    @mister_calm 20 дней назад

    I really like such short and informative videos.keep making them bro🫡

  • @luca4464
    @luca4464 17 дней назад

    I feel offended by the thumbnail , but thank you

  • @lolcat69
    @lolcat69 15 дней назад

    why pointers are so complicated? they are just a variable, that stores an address to something, and by derreferencing, you get the value at that memory location.... I used to use only high level languages before I maried with my current wife ( C ), and it was a really simple concept the whole pointers stuff lol

    • @youarethecssformyhtml
      @youarethecssformyhtml 13 дней назад

      Yeah this subject is overcomplicated for no reason. Pointers are a bit confused but not so complicated or even complicated. Just a bit confusing at first.

  • @slava6105
    @slava6105 18 дней назад

    Array to pointer decay and pointer arithmetic not covered.
    I am disappointed.

  • @see4yourself735
    @see4yourself735 15 дней назад

    Wheres the subway surfers second video in the corner?

  • @rch5395
    @rch5395 18 дней назад

    Imagine using a text editor instead of IDE

  • @LowPeak
    @LowPeak 15 дней назад

    well I knew before video how to use pointers... But actually I dont know why would I wanna do that... and dont tell me to have more effective code

  • @OptimusPrime-tb8tw
    @OptimusPrime-tb8tw 15 дней назад +1

    I bet 96 percent are not gen Z

  • @amirdashti5761
    @amirdashti5761 18 дней назад

    I never understood why should a pointer exist

  • @МухиддинМахмудов-б5щ

    I love gen Z 😂

  • @KrymmyOZY
    @KrymmyOZY 15 дней назад

    I not understand, send in TikTok format

  • @stavros222
    @stavros222 16 дней назад

    I clicked only to see if he used any funny language

    • @alfiegordon9013
      @alfiegordon9013 14 дней назад +1

      "you see when the address and desired content of a pointer becomes desynced, that's not very skibidi"

  • @DARKSTAR96
    @DARKSTAR96 21 день назад +3

    Be honest with yourself, most Gen Z people can't code.

    • @zedsanimations2242
      @zedsanimations2242 21 день назад +9

      You do realize gen Z stretches pretty far right? There are plenty of great gen Z coders

    • @alwayslg
      @alwayslg 21 день назад +1

      speak for yourself buddy

    • @zedsanimations2242
      @zedsanimations2242 21 день назад +6

      @@alwayslg considering I'm part of gen Z and I'm an embedded developer I think I'm doing pretty good

    • @ismotheis
      @ismotheis 20 дней назад +1

      tbh they like Rust and other things more. They don't quite get the charm of being able to shoot yourself in the foot if you want or even on accident. C isn't just the mother language, it's mother nature itself.

    • @zedsanimations2242
      @zedsanimations2242 20 дней назад +1

      @@ismotheis i think alot of the love is mostly the idea it it is "memory safe". but writing memory safe code isnt that hard if you have a rough idea of how the underlying hardware works

  • @0xkrypton
    @0xkrypton 16 дней назад

    Do you have a discord? If not create one i will help you and your community.