First Day learning the C Programming Language - Crash Course in C Programming

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

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

  • @radman999
    @radman999 2 года назад +18

    Mike, these are the best beginner C tutorials I have found online. You are a natural instructor. I love how you leave in your unexpected results instead of editing them. It is a really refreshing style that you have.

    • @MikeShah
      @MikeShah  2 года назад +4

      Thank you for the kind words Kevin! More to come!

  • @slavapavlov9473
    @slavapavlov9473 2 года назад +4

    1:05:44 Pass-by-Value.
    In C when you call a function, the variables values are copied and
    the copies of those variables are what is used in the function.
    An argument is the value we want to pass to the function for execution.
    A parameter is declared in the function header and used within the function.
    *An argument* is the variable itself.
    *A parameter* is the copy of the variable.
    #include
    int doubleTheValue(int parameter)
    {
    parameter = parameter * 2;
    return parameter;
    }
    int main()
    {
    int argument = 5;
    doubleTheValue(argument);
    printf("%d
    ", argument); //5, the argument itself wasn't changed
    argument = doubleTheValue(argument);
    printf("%d
    ", argument); //10
    return 0;
    }

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

      #include
      void doubleTheValue(int *parameter)
      {
      *parameter = (*parameter) * 2;
      }
      int main()
      {
      int argument = 5;
      doubleTheValue(&argument);
      printf("%d
      ", argument); //10, the argument was changed because we used pointers
      return 0;
      }

  • @franklin8184
    @franklin8184 2 года назад +9

    Simple , clean, direct, educative and organized. Thanks you for this gem!!!

    • @MikeShah
      @MikeShah  2 года назад +1

      You are most welcome!

  • @maizhouyuan4940
    @maizhouyuan4940 7 месяцев назад +2

    LIFESAVER! Heard from your student Jamie about your course website and RUclips channel, Mike, you're really helping me out with learning the C!

    • @MikeShah
      @MikeShah  7 месяцев назад

      Cheers, I'm happy to hear that!

  • @xamdp
    @xamdp Год назад +4

    Just finished the part 1 of the series, unfortunately not in a day but rather a week, I learned a lot and understand more than ever c series out there, I loved the topics: structs, pass-by-value, and linked list. Also, I use obsidian to keep track of my notes and nvim as for my ide. Want to say thank you Mike for these free resources you're giving for free.

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

      Cheers, thank you for the kind words!

    • @kelechiihewulezi2561
      @kelechiihewulezi2561 11 месяцев назад

      @@MikeShah which programming languages are best in implementing a library that will be used for identifying programming & markup languages in code snippets

  • @samdavepollard
    @samdavepollard Год назад +3

    oh wow - i only just realised that in amongst all your other goodies you have this C series
    can't stop - i have some videos to work my way through :-)

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

      Cheers! Enjoy! 😀

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

      @@MikeShah
      Mike: 'one day these compilers are going to write the code for us, right?'
      chatGPT: 'hold my beer'😀
      super useful video - many thanks for sharing your knowledge; on to the rest of the series

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

      @@samdavepollard hehe cheers!

  • @bobdobbs8397
    @bobdobbs8397 2 года назад +8

    I like your presentation setup and the pace of your lessons. Thanks for the quality tutorial.

    • @MikeShah
      @MikeShah  2 года назад +1

      Thank you for the kind words!

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

    Thank you Mike. This is probably the best crash course on C I've ever seen.

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

      Cheers, thank you for the kind words!

  • @sarahwitzig
    @sarahwitzig Год назад +3

    This is such a great introduction to the language. Thanks so much for the effort you put into creating this content, as well as the decision to make it publicly available.

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

      Cheers! Thank you for the kind words!

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

    Hello, i'm french and your tutorial is very clear and clever. Thanks a lot for your work!

  • @jonathanndawula8584
    @jonathanndawula8584 9 месяцев назад +2

    I Believe I have found a great c instructor, you were born for this Mike, thank you for this opportunity

    • @MikeShah
      @MikeShah  9 месяцев назад

      Cheers, thank you for the kind words!

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

    you're are a beast man helped me understand how to use both valgrind and gdb so quickly

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

      You're most welcome!

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

    i hope your lesson about C and generally other programming language that you did will be exist in the future. thanks

  • @edgarurmeneta
    @edgarurmeneta 6 месяцев назад +2

    Took me like a month, but I finally finished the video!!!! Thank you!!!!!!!

    • @MikeShah
      @MikeShah  6 месяцев назад

      Well done! You're well on your way -- and the later videos will revisit and reinforce many of the ideas discussed here.

  • @youcefmantas4944
    @youcefmantas4944 4 месяца назад +2

    very very good video i've watched it again and each time i learn more , can you please make tutorials about OS (Linux) , maybe some networking , Kernel , compilers any of these topics and that would amazing cause you are extremely great at explaining things THANKS A LOT

  • @iany1606
    @iany1606 2 года назад +5

    Awesome tut! Thanks Mike!

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

      Thank you for the kind words!

  • @dhanushs1802
    @dhanushs1802 2 года назад +4

    Excellent teaching. Very well explained. Thank you :)
    Hope i can build an useful application after gaining certain level of understanding of the language.

    • @MikeShah
      @MikeShah  2 года назад +1

      You are most welcome! Yes, one day--keep learning each day little by little!

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

    Hi Mike. Thanks for the series!
    Props to you for using a simple text editor in your terminal and not some complicated IDE.
    I tried following other tutorials on YT a few times but was always overwhelmed right from the beginning with all the complicated tools they typically use in such videos.
    But now everything just clicked into place:
    1. You edit your source code (which in fact is a simple text file).
    2. Then you feed it to the compiler.
    3. And then you run the executable.
    That's all there is to it!
    Even though I can use any text editor (now I know I don't need any fancy tools to code),
    I decided to install vim and it feels like magic.

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

      It took me more than one day to finish the video but I really enjoyed it!
      It's just I'm simultaneously learning basic programming concepts and vim navigation, so yeah... blah, blah, excuses. :D
      But for real, thanks a lot for the crash course, Mike!

  • @slavapavlov9473
    @slavapavlov9473 2 года назад +4

    37:18 How come the *countdown* function is void?
    Void functions should not return anything, should they?
    And yet, inside our function we literally say *return countdown(n-1);*
    I mean, I sort of get it.
    It doesn't return a value to the calling function. It simply calls itself recursively.
    That's what the *return* means in this case.
    But this syntax is quite confusing, to be honest.

    • @MikeShah
      @MikeShah  2 года назад +4

      void functions are a little strange, and some languages disambiguate this idea by giving them another name. 'return' in a void function essentially means, 'finish the function and go back to wherever the function call was made'. When we 'return countdown(n-1)`, we're saying , return after you call and finish performing another countdown (countdown itself--it's recursive) .

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

      @@MikeShah thanks for the clarification!

  • @notsky23
    @notsky23 2 года назад +5

    Thank you for the tutorial Professor!

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

      You are most welcome!

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

    I've taken quite a few C tutorials, but never once have I seen an example like you've given concerning the 'address of' operator enclosed in parentheses with a pointer. It made me have an 'aha' moment. 💡
    printf('%d
    ", *(&x));

    • @MikeShah
      @MikeShah  2 года назад +1

      Cheers! Adding the parentheses I think also helps folks think of operators as functions, and it this context (i.e. when we're doing something with variables, i.e. operating on them) it helps make things more clear!

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

    10:31 why? I don't see any problem, x is a variable it can take any value, furthermore u specified the domain of x which is the integers (?)
    y=x+1
    when x = 42 y = 43
    when x = 32 y = 33

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

    Amazing tutorial! Thank you!

    • @MikeShah
      @MikeShah  2 года назад +1

      Cheers, thank you for the kind words!

  • @Ptr-NG
    @Ptr-NG 8 месяцев назад +2

    Good stuff... thank you!

  • @slavapavlov9473
    @slavapavlov9473 2 года назад +1

    5:22 When our compiler sees
    *#include** *
    it automatically "injects" the source code of the Standard I/O library into our source code, right?
    Does it bring the source code of the entire library
    or only those functions that we actually use in our source code?
    I mean, if I only use the *printf()* function in my helloworld.c,
    the compiler will inject the source code of that function only,
    and it won't copy source code of, say, the *scanf()* and *puts()* functions, is that correct?

    • @MikeShah
      @MikeShah  2 года назад +1

      Ideally a smart 'linker' will only bring in the symbols actually used. :)

  • @Programeris
    @Programeris 3 месяца назад +2

    #include (👍) epic stuff first lesson, is over but i wanna resit it x2 more times maybe more :) very practical and precise while ! too much theory overload. (nononsence)

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

    1:17:08 I get no warnings when I use %d (instead of %ld).
    ruclips.net/video/cGoLFWHVFLE/видео.html
    Do I need to use some special compiler flags to get warnings?
    I don't want gcc to be too smart and fix problems in silent mode for me.

    • @MikeShah
      @MikeShah  2 года назад +1

      Try using -Wall . Otherwise, try updating to a later version of gcc or clang. I believe I'm using at least version 9 in this series.

    • @slavapavlov9473
      @slavapavlov9473 2 года назад +1

      @@MikeShah Thank you, Mike! The -Wall flag helped.
      I wonder why it isn't activated by default like in your case.
      My compiler is up to date btw. It's gcc-11.2.0-3.

    • @MikeShah
      @MikeShah  2 года назад +1

      @@slavapavlov9473 I agree it should be a default, strange it is not on your system.

  • @idellius7505
    @idellius7505 11 месяцев назад

    This video was outstanding and cleared up a lot of little things I had trouble grasping with C, so thank you very much for making this!
    Quick question though: Did you really need to make the arguments with the same naming conventions in the function declarations as it was in the actual definition -- or was that done just for clarity for the viewers?

    • @MikeShah
      @MikeShah  11 месяцев назад +1

      Cheers! You do not need to actually match arguments in function declaration and function definition (in declaration you can even omit them). I like to put both for consistency however.

  • @youcefmantas4944
    @youcefmantas4944 5 месяцев назад +2

    very very good Tutorial

  • @asterixx6878
    @asterixx6878 5 месяцев назад +1

    Java? Python? C++? Hahahaha.....
    C is the only programming language made for real men!
    Great video, Mike!

    • @MikeShah
      @MikeShah  5 месяцев назад

      Cheers! Whenever I think about learning a programming language, I think about how that language might shape how I think about programming. With C, after you learn the basics, I've found that C helps me think about 'data layout' and 'data-oriented paradigms' perhaps in a better way than other languages (and other languages help me think about other topics in computer science in better ways).

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

    Even if you leave n as a positive integer, with this assert it will do core dump, because one iteration n is going to be 0, and the assert will fire before the program can react with a return for n below 0.

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

      True, base case should be n

  • @jonathanndawula8584
    @jonathanndawula8584 9 месяцев назад +1

    So Mike I wanted to ask if you can use node_t when declaring next pointer in the struct ??

    • @MikeShah
      @MikeShah  9 месяцев назад +1

      You could, but you will need to forward declare the struct with the typedef. See example below.
      typedef struct node node_t;
      struct node{
      node_t* next;
      };

    • @jonathanndawula8584
      @jonathanndawula8584 9 месяцев назад +1

      @@MikeShah thanks 👍

  • @nagenHARP
    @nagenHARP 6 месяцев назад +2

    from where i can learn python ? please suggest .

    • @MikeShah
      @MikeShah  6 месяцев назад

      There will be something on this channel in a few weeks time.

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

    28:20 italian flag 🤌

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

      viva Italia! Good eye!

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

    40:22 I get a 'negative number' printed out even with *%i* format specifier:
    ruclips.net/video/1zBq62HNYMs/видео.html

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

      I'm assuming your argument is still 'unsigned int' and you're passing in a negative number?

    • @slavapavlov9473
      @slavapavlov9473 2 года назад +1

      @@MikeShah Yep, I copied your 40:22 example and replaced *%d* with *%i* in the *printf* function as you suggested in the text note. The rest is the same.
      When our argument is *unsigned int* and we're passing in a negative number,
      it seems like both *%d* and *%i* format specifiers give us the same result:
      enormous negative numbers in the output.
      I recorded a short video to show you what I did. The link is in my comment above.

    • @MikeShah
      @MikeShah  2 года назад +1

      @@slavapavlov9473 Looks like the expected output. %i and %d are I believe equivalent in printf for printing decimal numbers. Because we are passing an unsigned number to an unsigned type (unsigned int), and then using a format specifier for a negative number, we are going to get an 'unexpcted result' which may indeed be negative.

    • @MikeShah
      @MikeShah  2 года назад +1

      I like the 'CInForeverAndADay' folder :)

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

      @@MikeShah sorry, my bad. I guess, I misunderstood your text note.
      I thought we're expected to get the correct output by using *%i* instead of *%d* in this particular situation.

  • @Biplab_Mahanty
    @Biplab_Mahanty 4 месяца назад +2

    I needed it man