enum | C Programming Tutorial

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

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

  • @fifaham
    @fifaham Год назад +2

    @7:35 it is amazing how software and hardware can talk to each others - I love those things - Thanks Kevin.

  • @r_be
    @r_be 2 года назад +3

    Would I be correct by saying that enum by default is not very memory friendly approach? What if each element of enum can only ever be initialized up to 255. Instead of assigning a single byte per each entry now we have 4 bytes allocated?

    • @PortfolioCourses
      @PortfolioCourses  2 года назад +2

      So I've never thought of that before, but I suppose that's true in the sense that a char could be used in that case. Because an enum is guaranteed to be able to store what int can store, which means it's going to be 4 bytes in practice on most systems/compilers, though it could technically possibly be more: stackoverflow.com/a/366026. If you were using A LOT of enums, like very, very massive arrays of enum type values, this distinction might become important if we could get away with just using char type instead or something else. Otherwise I don't think it would matter much in practice, but it's a good interesting question to think about. :-)

  • @inkyinc2541
    @inkyinc2541 Год назад

    So notice that when you change the value of Tuesday to 9. However, when you recompiled, your value for Wednesday changed to 10; What caused that to happen?

    • @PortfolioCourses
      @PortfolioCourses  Год назад

      It's essentially just "the way C works" that if we assign an integer to an enum value, then the next enum value will take on the next integer. So there isn't really a deeper reason than that. :-)

  • @ramendampfen
    @ramendampfen Год назад

    Great vid

  • @towtruckn
    @towtruckn Год назад

    Kevin great video! On Linux I found after assigning a value to a single element it changed all the elements around it ie. If Thursday is given the integer value 10 then by default Wednesday becomes 9 and Friday becomes 11. Wether this is the same on other compilers I have no idea but something to look out for.

    • @PortfolioCourses
      @PortfolioCourses  Год назад +1

      That's interesting thanks for sharing that Peter! :-)

    • @Vishwa2757
      @Vishwa2757 Год назад +1

      2:33 when tuesday = 9, wednesday value automatically gettiing changed to 10 in the output.
      but specifically given value like friday = 20 doesn't change.

    • @towtruckn
      @towtruckn Год назад +1

      @@Vishwa2757 Thank you! your right, and I must have missed it watching the video. Doing an experiment assigning Wednesday = 9 and Saturday = 22 I got the following output 0, 1, (9), 10, 11, (22), 23 indicating only subsequent numbers to those defined are affected.

    • @PortfolioCourses
      @PortfolioCourses  Год назад +2

      @@Vishwa2757 Thank you for that clarification! 🙂

  • @NikitaSafronov-y6i
    @NikitaSafronov-y6i 2 года назад

    God day, Sir.
    As I can see you use a mouse in the video, but at the same time you jump from one line to another in a split second.
    Question.
    Do you use some shortcuts or another auxiliary application? I have noticed, I spend a lot of time to reach my mouse and it is annoying =)

    • @PortfolioCourses
      @PortfolioCourses  2 года назад

      Good question! :-) I don't do anything too fancy... just moving the cursor really fast with the keyboard up/down keys, and I copy, cut and paste with keyboard shortcuts as well (Command-C, Command-X and Command-V on Mac, or Ctrl-C, Ctrl-X and Ctrl-V on Windows). A lot of developers try to use the mouse as little as possible because it's considered slower to switch between mouse and keyboard. I'm not that strict about it myself but I like to use shortcut keys when I can.

  • @justcurious1940
    @justcurious1940 Год назад

    Nice 🙃.

  • @inkblade00
    @inkblade00 Год назад

    thanks. :)