Just enough C to have fun

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ธ.ค. 2024

ความคิดเห็น • 176

  • @Kelsu_
    @Kelsu_ 4 หลายเดือนก่อน +88

    One of the best C classes that i have seen in my whole life, way better than the college classes i attended. I apreciate

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน +5

      Thanks :)

    • @Michaelno
      @Michaelno หลายเดือนก่อน

      Ok first comment, i'm about follow along. we will see :)

    • @presauced
      @presauced 23 วันที่ผ่านมา

      "C classes" HEH

  • @maxmustermann5590
    @maxmustermann5590 หลายเดือนก่อน +8

    Man I knew this stuff and still watched it to completion. You have a lovely style presenting and I could listen to you talk about nerdy topics all day

  • @ProVrakian
    @ProVrakian 4 หลายเดือนก่อน +46

    Thank you for treating your audience like adults. This is the right amount of fast-paced and insightful.
    I appreciate a video that is meant to inspire people to dig deeper.

  • @ivankevamo
    @ivankevamo 4 หลายเดือนก่อน +49

    Great job. I have to thank the youtube algorithm for suggesting your channel. Thanks a lot. Greetings from South America.

    • @hararrouhak
      @hararrouhak 4 หลายเดือนก่อน +1

      i agree with you and my greetings from Egypt 👏💪

  • @Artem1I9a
    @Artem1I9a 4 หลายเดือนก่อน +8

    The best explanation of how memory works that I've ever seen. Very clear. Thanks for your effort.

  • @simonegalli5453
    @simonegalli5453 3 หลายเดือนก่อน +3

    The step by step visualization of all the memories involved was reslly well done. Thank you to spread knowledge.

  • @greg-enjoyer-36
    @greg-enjoyer-36 5 วันที่ผ่านมา

    Maybe I've just not found other good resources but it's quite insane to think about how literally no one explains _why_ the heap is a thing. Your explanation is very clear and gives me context of what the purpose of creating the heap was in the first place, thank you!

  • @Humble_Electronic_Musician
    @Humble_Electronic_Musician 4 หลายเดือนก่อน +21

    The content and presentation is top notch.
    I also like your eloquent speech: I'm interested in low level programming, but even if i was not, I would probably listen to this vid.

  • @mikle1404
    @mikle1404 24 วันที่ผ่านมา

    Very good explanation, thank you so much for this. I'm still learning C fundamentals and I like to read/watch many different explanations of the same concepts to test my understanding of them. This is one of the best ones so far!

  • @kscd009
    @kscd009 4 หลายเดือนก่อน +5

    Gold mine of content. This deserves much more audience

  • @LuzHarlott
    @LuzHarlott 3 หลายเดือนก่อน +1

    Thanks for the video! I haven't used C in years and had forgotten how fun it is, this will be a great refresh for me :)

  • @laxmanneupane1739
    @laxmanneupane1739 3 หลายเดือนก่อน +1

    Just watched this. The density of information is quite spot on.

  • @4xl45cd
    @4xl45cd 2 หลายเดือนก่อน

    I came across the training series on C/C++ from sharing developments on different sites. I'm glad I came across it. There are many training series on C programming language, but none of them are as detailed and connected as you described. Thank you for your efforts. Greetings from Turkey. Good work.

  • @chowder9576
    @chowder9576 4 หลายเดือนก่อน +2

    I randomly saw this on my TH-cam feed and so glad I watched. I don't even code in C but it was interesting learning something new! I hope to see more videos! :)

  • @GreeneThumbs
    @GreeneThumbs 4 หลายเดือนก่อน +2

    I've recently started learning C, and this video is perfect. I really like the format and presentation. Thank you!

    • @50lek
      @50lek 4 หลายเดือนก่อน

      I need to learn C++ for work, and its also really complicated in my opinion. What do you think?

  • @andrewwdavid
    @andrewwdavid หลายเดือนก่อน +2

    honestly such a refreshing video on C,

  • @AndrewTSq
    @AndrewTSq 27 วันที่ผ่านมา

    I like this! It makes me feel like I understand it, cause you explain it so good .

  • @obrikash9123
    @obrikash9123 4 หลายเดือนก่อน +1

    I really enjoy your videos as i had some experience with c++ and i almost understand all of just C. I think this video format is great for people who are already informed about basics, pointers and memory concepts. Love from Moscow, Russia

  • @hasanhuseyinyurdagul5403
    @hasanhuseyinyurdagul5403 4 หลายเดือนก่อน +1

    The presentation and whole video overall was very smooth, even though I already knew this stuff, I watched until the end. Subscribed, very good content.

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน +1

      Appreciate it!

  • @pavalep
    @pavalep 3 หลายเดือนก่อน +2

    kay..thanks for this awesome series. Im a react native developer who is interested to learn thee nitty gritty of coding. but actually lacks the core concepts. will be following ODES series as i find the videos very enlightening👍

  • @caesarespinosa3131
    @caesarespinosa3131 2 หลายเดือนก่อน

    Magnificent classes you give Dear Kay, most grateful to you and thanks for your efforts

  • @giorgioripani8469
    @giorgioripani8469 28 วันที่ผ่านมา

    First time that I see a perfect description of stack mem vs heap mem
    I started learning C alongside Fortran like more than 10 years ago at university classes. Now I switched to Java and Python, but all the low level concepts still resonate a lot❤

  • @riebeck1986
    @riebeck1986 หลายเดือนก่อน +1

    Great video ! So much information, but is so well presented and clear !

  • @goingupandupandup
    @goingupandupandup 3 หลายเดือนก่อน

    This is the best lesson on C I have ever watched. Thanks a bunch

  • @gepacc
    @gepacc 2 หลายเดือนก่อน

    Some of the best programming content on TH-cam!

  • @lautarolopez9992
    @lautarolopez9992 2 หลายเดือนก่อน

    Your content is PURE GOLD Kay, thank you!

  • @NerdyX90
    @NerdyX90 หลายเดือนก่อน

    You are a fantastic teacher... thank you for this..

  • @charlesmarseille123
    @charlesmarseille123 4 หลายเดือนก่อน

    the explanation of the function pointer in the memory space is great. well done.

  • @calengo454
    @calengo454 2 หลายเดือนก่อน

    hello i love you this is literally the best c video on the internet

  • @axelqt1
    @axelqt1 2 หลายเดือนก่อน

    Thanks a lot for this, others would have taken at least 4 hours for this amout of information, really appreciate it

  • @MrAguaconazucar
    @MrAguaconazucar 3 หลายเดือนก่อน

    This is a work of art. Keep up with the good job. Im thankful for this resource

  • @dixztube
    @dixztube 4 หลายเดือนก่อน

    Just had to comment again and I’m a new subscriber. This was so good. You’re very intelligent and explain things well. Made all this seem very easy

  • @UliTroyo
    @UliTroyo 4 หลายเดือนก่อน +12

    C really is fun! And because it's been around for so long, used textbooks on Amazon are dirt cheap.

    • @stefanalecu9532
      @stefanalecu9532 4 หลายเดือนก่อน

      I don't see you making the same argument for Fortran and Pascal ;)

  • @deutschWallah
    @deutschWallah 4 หลายเดือนก่อน +1

    Hey Kay, this is really good class. I hope you take more of such classes, maybe involving more of gdb and valgrind and other mess which we usually face 🙂 Really really good work.

  • @modolief
    @modolief 4 หลายเดือนก่อน +1

    Good explanatory content for beginning C programmers.

  • @devoiddude
    @devoiddude 4 หลายเดือนก่อน

    I have a background in java and actually started in C last week, was openai to help me show examples etc but this video was very helpful, thanks so much!

  • @onurolce
    @onurolce 3 หลายเดือนก่อน

    What a calm person you are !:) First time I've watched your video. So let me check your playlists :)

  • @kriszenn1125
    @kriszenn1125 3 หลายเดือนก่อน

    The for-loop is syntactic sugar for a while loop with the following setup:
    initialization;
    while (condition) {
    increment;
    }
    and its equivalent for-loop
    for (initialization; condition; increment) {
    }
    EDIT: i think it's easier to think of a for-loop as:
    for (before; during; after) {
    }
    but that can be confusing too. "During" is the condition that is technically checked *before* running the , but one can say that it's constantly being checked *during* the loop. "Before" is self-explanatory, but "after" seems confusing. "After" is code run after the has done its thing.

  • @AnimeKing-m2t
    @AnimeKing-m2t 4 หลายเดือนก่อน

    Such an amazing talk...pure code and explanations.

  • @veto_5762
    @veto_5762 4 หลายเดือนก่อน

    I don't even know why I'm watching this since I've been using c++ for like 3 years now, still nice video

  • @codephilosopher
    @codephilosopher 4 หลายเดือนก่อน

    Thank you, your videos are very enjoyable to watch.

  • @bradmccoy1747
    @bradmccoy1747 4 หลายเดือนก่อน

    I enjoyed this video. I liked how you connected everything together. I am a less than beginner level in C. I have been in Assembly for quite a while now. I have have bounced into all of these concepts during my own writes and you lay it out so nicely and I like how it doesn't have to be fast and skippy. The whole concept of a function returning data has bothered me for some time now. The concept is an abstraction from what is really happening. A function call is really just a sugary goto but with a fancy way to return to the next line after the goto. And when the function does return; it just cannot carry data with it - LOL. But it could have altered the values in the registers. And our ancestors created a fancy trick by altering the RAX (EAX, AX, AL, AH) register; then copying that new value into a variable on the caller side. This gave the illusion in our beloved gen 3 languages that a function may return a value. But it really didn't, it just changed a register value. My point is that now everyone wants to return big stuff from functions and it has just gone too far. Ok - thats my rant for the day. And your video supports my thoughts with realistic examples. Love it!

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน +1

      Thanks for the comment! Really enjoyed reading it. I'm looking forward to getting more into building up the 'function' abstraction through assembly in the next couple videos. Was just playing around with it today actually. Exciting!

  • @dominichawkins7997
    @dominichawkins7997 3 หลายเดือนก่อน +1

    Poor hand writing is a sign of intellect':] You rock!

  • @adekorir
    @adekorir 4 หลายเดือนก่อน +1

    perfect for my reintroduction to the c programming language.

  • @1732ashish
    @1732ashish 4 หลายเดือนก่อน

    thanks for this crisp, to the point video.

  • @nazneenzafar743
    @nazneenzafar743 4 หลายเดือนก่อน

    Thanks for the lesson. I hope you keep up with producing awesome content.

  • @SuncoastSoftware
    @SuncoastSoftware 2 หลายเดือนก่อน

    I wish you taught c#, I love the way you "teach".

  • @ItsRyanStudios
    @ItsRyanStudios 4 หลายเดือนก่อน

    I've been having a crisis of meaning lately; I love my work as a web dev, but every day I'm just writing bloat.
    I was looking for a good intro to C or embedded development; grateful the algorithm sent your channel to me 👍

  • @MarianoBustos-i1f
    @MarianoBustos-i1f 4 หลายเดือนก่อน

    This comment works roughly as you would expect it: you make an awesome video, I comment nice stuff.

  • @offlinemark
    @offlinemark 4 หลายเดือนก่อน

    Great video, thanks! I'm using C to build a little hobby os for fun, and this is a nice refresher video :)

  • @betoperalta701
    @betoperalta701 3 หลายเดือนก่อน +1

    You have a nice smoothing voice

  • @Jalae
    @Jalae หลายเดือนก่อน

    malloc is like a sharp knife. cutting yourself is 100% every time the user's fault. every memory leak is a #skillissue.
    that said, if this is supposed to be "enough C to have fun with" probably better to not even have mentioned it. malloc is the literal line I would classify as "enough to be dangerous". im not sure where else the line could even be. It is by far the most dangerous thing C has, to the point that entire languages are created to solve the "malloc problem".

  • @PowerLlama
    @PowerLlama หลายเดือนก่อน +1

    "those fast counters will know" lol

  • @caspersro
    @caspersro 3 หลายเดือนก่อน

    i like your way of giving the information good work really i have a little knowledge of C Language so i may ask you to teach me and others like me C Language like this way
    Thank you in Advance 😍😍😍😍😍

  • @twenty-fifth420
    @twenty-fifth420 2 หลายเดือนก่อน

    For better or worse, this is the video I need to see. I am working on a modern immediate GUI for myself, for fun (and maybe 'profit' for as far as I can go with FOSS!).
    Better late then never I suppose!
    Edit: 2:22 *shoves nerd glasses* What you refer to as 'Lie-nuhx' is in fact, 'GNU + Linux' or simply the 'Linux' stack.

  • @johnsteve1276
    @johnsteve1276 3 หลายเดือนก่อน

    Great content. Appreciate your hard work. Btw, could you make a video about C++ ?!

  • @latch909
    @latch909 3 หลายเดือนก่อน

    This rules, someone lovely making nice videos about C what could be better

  • @badamson
    @badamson 3 วันที่ผ่านมา

    did you know that array[1], as well as... [array]1 are both valid C code, because in the first case we do (pointer arithmetic) pointer to first element + index, and in the second we do index + pointer to first element, which is the same!

  • @mantra578
    @mantra578 4 หลายเดือนก่อน

    i really had fun watching this

  • @Gersberms
    @Gersberms 4 หลายเดือนก่อน

    I really love your style of presenting the source, the structure of your story, and just the easy going nature of it all. I will gripe about using two spaces for indentation, so -1 point for that, but +2 points for showing simple macros so that I now no longer feel that I need to avoid them. Thanks! Oh and, printf is super slow because I believe it's monstrously complex, so that might be worth mentioning (plus security risks I believe). And is make really worth using?

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน +2

      Thanks! And all good points - I can definitely feel the complexity of printf coming through when I reach for it :) Re: make, with these videos questions like that are often a balancing act. Could use a plain shell script but then learners might not remember make at all and that can be confusing later, or could go for something more fully featured and then you're going to also have to include setup instructions and risk diverting attention. My angle is often trying to put people in a position where they've encountered the right set of things to then go build on the basics later - rather than taking a sophisticated approach early on and getting muddled. Could easily argue for other tradeoffs though! Anyway, thanks for the comment :)

    • @Gersberms
      @Gersberms 4 หลายเดือนก่อน

      @@neoeno4242 You're right about make and your approach. This was more of a personal curiosity, and not a comment on your content. I got inspired by Handmade Hero that a batch file or shell script will suffice because usually it's just a few lines of mkdir, copy, gcc and run. So I have come to rely on a simple VS Code "skeleton project" as I clumsily called it that does these things: build, debug, and test. Whatever language I'll use is not even important because the concept works for whatever I'm making.
      You done any video on git yet? VS Code and git are a match made in software heaven.

    • @neoeno4242
      @neoeno4242  2 หลายเดือนก่อน

      Not yet! Good idea though, thanks :)

  • @z0rba566
    @z0rba566 3 หลายเดือนก่อน

    thank you yt! thank you Kay! can I request for a holy-C playlist !

    • @neoeno4242
      @neoeno4242  3 หลายเดือนก่อน +1

      Just added playlists to my todo list!

    • @Satyam1010-N
      @Satyam1010-N 2 หลายเดือนก่อน

      ​@@neoeno4242 pdf too, I find enterprise design architecture very hard , basic intermidate is on yt , I wish get to to projects live ( pre record ed)

  • @4ozmane
    @4ozmane 4 หลายเดือนก่อน

    The clip cuts are nice to keep things moving, keep making educational videos plz

  • @calderarox
    @calderarox 3 หลายเดือนก่อน

    this is a great video! thanks for sharing

  • @FocusAccount-iv5xe
    @FocusAccount-iv5xe 4 หลายเดือนก่อน

    This was wonderful. Thanks!

  • @clintquasar
    @clintquasar 4 หลายเดือนก่อน +1

    Great teacher!

  • @Tenshi-sk8ty
    @Tenshi-sk8ty 4 หลายเดือนก่อน +43

    bro is majestic

    • @2wheels2
      @2wheels2 4 หลายเดือนก่อน +1

      bro is trans

    • @thomasredden3159
      @thomasredden3159 4 หลายเดือนก่อน +6

      she is slaying physically and intellectually 💅

    • @bmno.4565
      @bmno.4565 4 หลายเดือนก่อน

      Agreed, what a fierce flow.

  • @Marc-Tu
    @Marc-Tu 4 หลายเดือนก่อน

    Nice video. And I like your shirt. It looks good on you.

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน

      Thanks!

  • @dixztube
    @dixztube 4 หลายเดือนก่อน

    Wonderful job!

  • @uuuweee
    @uuuweee หลายเดือนก่อน

    I tried printing junk data just like at 27:04 on my machine using Clang version 14.0.0-1ubuntu1.1, but the data was not junk. When I used GCC, I got a Segmentation fault. After some research, I found that by setting the -fsanitize=address and -fsanitize-address-use-after-return=always flags, it detects stack use and fails. I wonder why I couldn’t print a junk value on my machine.

  • @ramonasuncionbatista
    @ramonasuncionbatista หลายเดือนก่อน

    Great video!

  • @mrinalyadav4261
    @mrinalyadav4261 4 หลายเดือนก่อน

    this series is grt.

  • @ytbacc0001
    @ytbacc0001 4 หลายเดือนก่อน +1

    Thank you for this video

  • @egu00
    @egu00 4 หลายเดือนก่อน

    enjoy your video, thanks!

  • @werren894
    @werren894 3 หลายเดือนก่อน

    This is awesome!

  • @Marco-pz5dx
    @Marco-pz5dx 4 หลายเดือนก่อน +59

    I liked the video, but honestly probably a bit too hard for beginners. Honorable mission though. In particular, the attempt to simplify some topics may actually end up misleading: on discussion about returning strings, I can see how you really try to explain variables' lifetimes but without mentioning them explicitly only focusing on the example. I would try to instead insist on the notion of lifetime and then go on explaining why callee variables on stack cannot outlive their lifetime and be accessible from parent (i.e. they "expire" upon return, and thus caller's attempt to access that now potentially overwritten stack memory is flawed). I would also showcase how a struct wrapping the fixed size array is possible due to return semantics.

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน +30

      Such an interesting perspective - thanks for sharing, appreciate it and I'm sure others will too.

    • @jamesdoe2139
      @jamesdoe2139 4 หลายเดือนก่อน +1

      @neoeno4242 do you have a Discord server/are you a Discord user?

    • @parallelno
      @parallelno 3 หลายเดือนก่อน +2

      Thank you for the video. Please review the memory dump you're showing. Each line should display 16 bytes, but yours only shows 8. Additionally, please verify the byte order. On most modern architectures, it should be little-endian, meaning the smaller byte appears first.

  • @jimshtepa5423
    @jimshtepa5423 4 หลายเดือนก่อน +2

    do you have a map of topics you plan to cover in the next10-15 videos?

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน +7

      Working on it :) At the moment I'm working towards creating binary executables from scratch as a little milestone. That will involve spending a bit more time working with binary data, file formats, syscalls, and ASM. I think my planning will solidify in the next few months - will share more as that solidifies!

  • @ru2979
    @ru2979 หลายเดือนก่อน

    Please make more C videos 😢🙏🏼🙏🏼🙇🏼🙇🏼Please please ❤

  • @bzboii
    @bzboii หลายเดือนก่อน

    7:20 aaaand you’ve reimplemented godbolt :)

  • @MagicalCritical
    @MagicalCritical 2 หลายเดือนก่อน

    can we have some cintent on testing (windows) ?

  • @antonio_carvalho
    @antonio_carvalho 3 หลายเดือนก่อน +1

    Spec requirement: high tech title card. ☑️

  • @josephlagrange9531
    @josephlagrange9531 4 หลายเดือนก่อน

    Hi, I subscribed yesterday.

  • @rescyy2235
    @rescyy2235 4 หลายเดือนก่อน +3

    What text font are you using?

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน +6

      Largely: Monaspace Xenon for the code font, and Mona Sans for the rest. Sometimes I mix up the monaspace font families though :)

  • @t1nk3rtail0r
    @t1nk3rtail0r 3 หลายเดือนก่อน

    Very, very good !

  • @onurolce
    @onurolce 3 หลายเดือนก่อน

    12:46 unsigned char MAX should be +255 , am I wrong ?

  • @Isaac-zy5do
    @Isaac-zy5do 4 หลายเดือนก่อน

    At 14:00 i think it should either be nums[0] = 0x10; nums[1]=0x20; etc or 0a 14 1e in memory

  • @VforVanish
    @VforVanish 4 หลายเดือนก่อน

    If the memory is allocated with malloc and returned, if we call printf it wont be corrupted no?
    That problem was because the array was on the stack?
    Very interesting videos an great teacher!

    • @neoeno4242
      @neoeno4242  3 หลายเดือนก่อน +1

      Yes that's correct!
      Though if we use malloc in the function then we will have to decide when to free or 'give back' that memory (since in C nothing will free it up automatically and if the function is called repeatedly this will eventually use up a lot of memory).
      So string functions in C instead typically take a pointer to a buffer as an argument and then alter that buffer. That way the caller is responsible for allocating and freeing memory however they see fit.

  • @zyhru
    @zyhru 3 หลายเดือนก่อน

    Isn't the second solution with malloc more flexible since there might some situations where you don't know length of the string at compile time?

    • @neoeno4242
      @neoeno4242  2 หลายเดือนก่อน +1

      Yes - it definitely has that advantage. Though it has some other disadvantages, for example that allocating memory takes a bit of time and someone has to remember to free it up. Many (not all) C programmers prefer fixed-length buffers to malloc for certain tasks. If you're used to higher level languages this might feel weird though!

  • @DeeBash
    @DeeBash 2 หลายเดือนก่อน

    @19:55 Is it padding, between two string addresses? exactly at 0x0014 (based on correct addressing).
    if it's not padding then why extra 00 stored in between two strings. I can understand the null pointer at the end of strings, but why extra zero at 0x0014

    • @neoeno4242
      @neoeno4242  2 หลายเดือนก่อน +1

      Good question - that one is just arbitrary. I wanted to indicate for the purposes of the demonstration that I'm not describing precisely where strings will definitely get put in memory. The values aren't packed perfectly so that people won't accidentally assume that they are. In the real world, there might be many reasons - could be padding/alignment, could be the C compiler is deciding to store other values there, could be other reasons, or it could be that they get packed perfectly!

    • @DeeBash
      @DeeBash 2 หลายเดือนก่อน

      @@neoeno4242 thank you for the explanation. I thought C is just like assembly(.align 4). But from your explanation, we can't be sure how data is packed/ordered in memory. I'm sad now.

  • @salim444
    @salim444 4 หลายเดือนก่อน

    the first this I do in an empty main is allocate 5k array just for the sake of it. Feels great to allocate arrays and then free it

  • @fazin85
    @fazin85 2 หลายเดือนก่อน

    great video :)

  • @sanctuary_of_soul
    @sanctuary_of_soul 4 หลายเดือนก่อน

    at 8:32 i believe there is something off in how the sentence is composed logically.
    "...it just gets inlined straight into the file, and everything in the other C file gets chunked into the C file we are including from..."
    "...chunked into the file we are including from..." does it?
    Or am i missing something?

    • @BoardGameMaker4108
      @BoardGameMaker4108 4 หลายเดือนก่อน

      You are right, that might be a small mistake. For anyone looking at this later, it just does a simple copy and paste (from the other file into your file).
      By convention, we also generally separate code into two files "header files" (.h) contain code that you want to be copied into other files (you can #include them). Implementation files (.c) contain code that you don't want to (or can't) copy around. One thing to note is that you cannot copy function implementations, so leave the implementation in a .c file, and the declaration in the .h file. This lets you use the function in other places without having multiple functions with the same name causing a linking error.

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน

      Yes it's not super clear - thanks for flagging and also to @BoardGameMaker4108 for clarifying. Appreciate it.

  • @ga1agen
    @ga1agen 4 หลายเดือนก่อน

    19:13 - what the hell each 4 bits have its own address? x86 cpus can only address minimum a one byte(8 bit)... and other cpus, except microcontrollers( where part of memory can be 1-bit addressed for gpio)

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน +2

      Ah yes, my mistake - thanks for flagging. I mistakenly gave each digit its own address, which isn't correct! Should be something more like this: link.excalidraw.com/readonly/KooN4ScH7IO4QuRsZtEG

  • @vasantheee
    @vasantheee 4 หลายเดือนก่อน

    Is it possible that the assert without printf could also fail at 25:10 because buffer variable is reallocated to something else? I am not sure why it is stated here that the program fails only after printf is added.

    • @anon_y_mousse
      @anon_y_mousse 4 หลายเดือนก่อน

      Because it's on the stack and the stack is changed after calling printf(). Literally any function which makes use of some stack space would have the same effect.

    • @vasantheee
      @vasantheee 4 หลายเดือนก่อน

      ​@@anon_y_mousse but even without modifying our program, it is possible that stack memory could be allocated or used by some other program and there is no gurantee this program would work everytime (without printf Or any other change) right?

    • @anon_y_mousse
      @anon_y_mousse 4 หลายเดือนก่อน

      @@vasantheee I certainly wouldn't depend on it being valid after the function call, but OS's typically will allocate a stack per thread or process, depending on configuration. However, depending on what the compiler does to your code, even if you don't make a function call, it's likely that data higher up on the stack could be instantly invalidated upon function return. For older chips and microcontrollers, if you have a stack at all, then all parameters would be passed on the stack, generally, and then upon return, anything allocated off the stack inside the function would be instantly invalidated. For newer chips, it's pretty much a given that parameters will be passed by register if you have few enough parameters, but the compiler might very well finagle your code such that it has to push and pop some data around the function call which would thus invalidate the array.
      In short, you don't have to worry about other programs running on the system invalidating your stack because your own program will likely do it without you directly seeing the effects.

    • @vasantheee
      @vasantheee 4 หลายเดือนก่อน

      @@anon_y_mousse thank you. So we cannot count on the program being successful like it happened at 25:10 all the time, right?

    • @anon_y_mousse
      @anon_y_mousse 4 หลายเดือนก่อน

      @@vasantheee I would say we shouldn't ever count on it. The thing to remember, if you want to work with an array, pass it into the function. If you want it to be resizable, then pass the address of the pointer. If you want to do dynamic arrays, then consider using a struct and passing the address of that struct, say typedef struct { size_t length; int data; } array_t; and just replace int with whatever type you wish to have an array of. You could even make the array type something like int_array_t or array_int_t or whatever name you feel like.

  • @richardappow6770
    @richardappow6770 4 หลายเดือนก่อน

    what code editor are you using here?

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน

      VS Code :)

  • @seekyou
    @seekyou 4 หลายเดือนก่อน

    watching this quite cool video feels a little bit like stealing for the goodness received for free!

  • @estebanmorales9736
    @estebanmorales9736 3 หลายเดือนก่อน

    incredible

  • @energy-tunes
    @energy-tunes 3 หลายเดือนก่อน

    Very high quality channel

  • @sadramohh
    @sadramohh หลายเดือนก่อน

    3:47: "Lowercase Zero" xD

  • @avizyt_official
    @avizyt_official หลายเดือนก่อน

    There are two type of programmers in this world by pronunciation of Linux
    1. Leenax
    2. Lainax
    I'm leenax type and you?

  • @JohnDoe-kh3hy
    @JohnDoe-kh3hy 4 หลายเดือนก่อน +1

    Excuse me, young fellow. May you please provide me with some advice on how to become a professional (or better yet, dangerous) C programmer. Thanks a bunch

    • @neoeno4242
      @neoeno4242  4 หลายเดือนก่อน +1

      By way of advice on going pro with C I'm not sure I have anything really revelatory - it does appear like safer systems languages like Zig, Go, Rust are gaining popularity lately. If you're looking into C though, common pro books I see recommended are: C Programming, A Modern Approach by K N King and The C Programming Language by Kernighan, Richie. On top of that, write a lot of code and ideally run it yourself day to day :) Why use the built in `ls` when you can make your own and feel all the pain when it doesn't work? Wishing you good fortune.