Advanced C #1: Function Pointers

Поділитися
Вставка
  • Опубліковано 28 тра 2024
  • Function pointers, how are they useful and how to use them.
    Stackoverflow post with shellcode example: stackoverflow.com/questions/1...
    Explain weird C in English: cdecl.org
    Socials:
    Github: github.com/cacharle
    Linkedin: / charles-cabergs

КОМЕНТАРІ • 72

  • @cacharle
    @cacharle  Місяць тому +9

    I zoom in more in later tutorials
    FYI: This series of videos doesn't have any particular order to it, you don't need to watch the early videos to watch the latest ones.

  • @ulrich-tonmoy
    @ulrich-tonmoy 5 місяців тому +129

    its definitely not a good idea to put # after C

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

      Indeed, tricking the C# devs into learning C, that was my master plan all along

    • @ulrich-tonmoy
      @ulrich-tonmoy 5 місяців тому +19

      @@cacharle evilest thing one can do to C# dev

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

      @@cacharle genius, subscribed

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

      @@cacharle The hero we needed

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

      I skipped this video three times cause of this the YT algo just knows I like C so it was persistent 😂

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

    my favorite thing about function pointers is that you can store them in a data structure and call any function with the same signature

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

      True it's kind of like having methods in c++ except you get runtime polymorphism because you can reassign the function pointer to something else, you can obviously do the same thing in c++ if you specifically want to do that too but generally you would just use normal methods in c++

    • @moritzrank01
      @moritzrank01 13 днів тому

      what do you call polymorphism in a functional language?

  • @FF-hy4ro
    @FF-hy4ro 4 місяці тому +4

    Excellent video! We definitely need more of this.
    Once suggestion: the font size.
    At least 2 times bigger would be more readable.
    Thanks again for the video!

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

      thank you :), I've zoomed in even more in later videos.

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

    very useful, and good explanation! please keep it up.

  • @l.sureshkumar-lsk550
    @l.sureshkumar-lsk550 Місяць тому +2

    Pls increase font size for ease of viewing

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

    great video! it's so interesting that I'm finding lots of fresh videos about a language built more than 50 years ago. Is C becoming more popular, I wonder ?
    I love the simplicity of C, compared to other "advanced" languages like C++, Java & Rust. C is one of those easy-to-learn but hard-to-master thingies.
    thanks for sharing these little snippets of knowledge

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

      Thanks! Unfortunately, I don't think C (or simpler languages) are going to become more popular :') But I really hope I'm wrong about that.
      The only simple language that I've seen get traction is Go. I think C will stick around for a long time still so it's definitely worth learning.

    • @LeCockroach
      @LeCockroach 3 місяці тому

      @@cacharleto me, Go is just simple at the surface. If you dig just a bit under that and look at the std source code, you'll see for yourself it's not that simple at all, a lot of nasty stuff is hidden. But it's a good inspiration and a beautiful language to work with.

    • @cacharle
      @cacharle  3 місяці тому

      @@LeCockroach hmm, I've never dived in the Go stdlib source but if you have any example, I would be curious to look at them.
      I was just saying that out of all the language used widely in production, Go is the only simple on I could think of beside C.

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

    I was looking for some advance c tutorial yesterday night and here we go.

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

      Happy to serve :)

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

    The explaination is good. Good content.

  • @corbin_zip
    @corbin_zip 27 днів тому

    thank you! this is a phenomenal video and i'll be watching and working alongside the others on your channel as well

    • @cacharle
      @cacharle  27 днів тому

      Thanks, I'm glad you got something out of it 😄

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

    nice. I enjoy your explanations.

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

    I'm nowhere near advanced level in C..but I'm subbed now!
    Awesome content Sir!

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

      Thank you, I hope this series will make you better at C :)

  • @SeanCodingThings
    @SeanCodingThings 15 днів тому

    Nice concept. I love it.

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

    Thank you so much for doing this. Please continue on this series. I have subscribed and liked ur videos and I am going to watch all of them. It's hard to get an advanced c programming course anywhere else.

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

      I'm glad you like it, I'm not sure I will continue the "Advanced C" series but I do plan on making more C related videos and streams with similar content where I dive in more obscure subjects trying to understand how stuff works under the hood.

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

    I thought this was C# 1.0 tutorial for a second. Well played😅

  • @mandcali7613
    @mandcali7613 3 місяці тому

    Hi Charles, you can zoom-in a bit so mobile watchers can see the text being typed. And so we dont need to zoom and pan. Thank you for your understanding.

    • @cacharle
      @cacharle  3 місяці тому

      It's more zoomed-in in the next videos

  • @1PercentPure
    @1PercentPure Місяць тому +1

    thank you!

  • @Brad_Script
    @Brad_Script День тому

    it's also used when you create a thread

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

    I wasn't confused, I know C is the Charlemagne of programming languages, top tier thumbnail

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

      Finally someone that gets it, I feel less alone now 😂

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

      @@cacharle a rare history buffs 🤝 C programmers

    • @sack-shaw
      @sack-shaw 4 місяці тому

      If C is Charlemagne then which language is Charles Martel?

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

      @@sack-shaw Hmm, a bit less known, slightly older, I would say Fortran or Algol😄

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

    Oh fuck the first couple of minutes i was thinking "Function pointers in C#? Damn, they change things fast!" But then i noticed "#include " and realised it's #1 is for the video number 1 XD

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

      No no, it's actually an extremely advanced C# tutorial. In fact, I managed to make C# so much better that it actually looks like C now

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

      @@cacharle lol

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

    What neovim plugins are you using to get synax errors and intellisense?

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

      I use the builtin LSP server of neovim and configure it with nvim-lspconfig: github.com/neovim/nvim-lspconfig
      For auto completion, I use nvim-cmp: github.com/hrsh7th/nvim-cmp
      My neovim config can be found here: github.com/cacharle/dotfiles/blob/03eb44293762bbbe7459b91a4c7bdf23e62a5bf6/config/nvim/lua/plugins.lua#L69
      And cmp config: github.com/cacharle/dotfiles/blob/03eb44293762bbbe7459b91a4c7bdf23e62a5bf6/config/nvim/lua/plugins.lua#L235

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

    great stuff! Could you do videos os efficient error handling/debbuging in C?

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

      I can definitely do a video about error handling. As for debugging, I mostly use printf out of lazyness.. I use gdb for really hard bugs occasionaly.
      A good way to "debug" is to have a assert() everywhere to check some condition that should not exist

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

    Even if its baiting C#. The typedef function pointer is the same thing as a delegate in C# but I think the return type is the last parameter. (Also its more fucked up and confusing then reading how pointers are allocated in memory in C, imo)

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

      I have 0 experience with C# tbh 😅 but it's nice to know that it looks like C.
      and the "bait" was accidental, I already had made too many thumbnails to change it when people made me notice it 🤣

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

      @@cacharle I'm thankful you make these videos. I was learning C and finished reading C - Programming Language 2nd Edition. When your video popped up on my feed.

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

    I was like "What? Since when C# has function pointers? You mean delegates?"
    *click*
    Oh it is C

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

      Yup, a lot of people get tricked but I'm too lazy to change every single title now 😂

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

    thankyou

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

    sweet

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

    Not me looking at this for 3 minutes before understanding that I was looking at C and not C# kek

  • @vikaskumar-oj2fr
    @vikaskumar-oj2fr 19 днів тому

    Tell me , from where i can study the whole c23 programming language?

    • @cacharle
      @cacharle  19 днів тому

      Here is the specification: en.cppreference.com/w/c/23

    • @vikaskumar-oj2fr
      @vikaskumar-oj2fr 19 днів тому

      @@cacharle thanks

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

    How can I learn more about pointers?

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

      I think writing your own linked list is a good exercise to learn about pointers (or any kind of data structure that contains pointers you need to do operations with)
      I used this *great* debugger pythontutor.com/c.html#mode=edit to learn more easily about pointers in school, it has a very nice way of visualizing pointers, hope this helps.

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

      This video is a good introduction to C pointers 'C: malloc and functions returning pointers': ua-cam.com/video/3JX6TyLOmGQ/v-deo.html
      It's at almost at Charles level regarding teaching :o), but it's strait forward way of explaining about C pointers have have helped many viewers.

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

    Must be bigger.

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

      yo moma big enough tho

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

    🤣🤣 I swear it was c#

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

      yup, a lot of people do 😅