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.
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; }
#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; }
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 which programming languages are best in implementing a library that will be used for identifying programming & markup languages in code snippets
@@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
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.
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
Excellent teaching. Very well explained. Thank you :) Hope i can build an useful application after gaining certain level of understanding of the language.
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.
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!
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.
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) .
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));
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!
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
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?
#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)
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 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.
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?
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.
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).
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.
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; };
@@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.
@@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 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.
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.
Thank you for the kind words Kevin! More to come!
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;
}
#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;
}
Simple , clean, direct, educative and organized. Thanks you for this gem!!!
You are most welcome!
LIFESAVER! Heard from your student Jamie about your course website and RUclips channel, Mike, you're really helping me out with learning the C!
Cheers, I'm happy to hear that!
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.
Cheers, thank you for the kind words!
@@MikeShah which programming languages are best in implementing a library that will be used for identifying programming & markup languages in code snippets
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 :-)
Cheers! Enjoy! 😀
@@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
@@samdavepollard hehe cheers!
I like your presentation setup and the pace of your lessons. Thanks for the quality tutorial.
Thank you for the kind words!
Thank you Mike. This is probably the best crash course on C I've ever seen.
Cheers, thank you for the kind words!
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.
Cheers! Thank you for the kind words!
Hello, i'm french and your tutorial is very clear and clever. Thanks a lot for your work!
Merci beaucoup!
I Believe I have found a great c instructor, you were born for this Mike, thank you for this opportunity
Cheers, thank you for the kind words!
you're are a beast man helped me understand how to use both valgrind and gdb so quickly
You're most welcome!
i hope your lesson about C and generally other programming language that you did will be exist in the future. thanks
Cheers!
Took me like a month, but I finally finished the video!!!! Thank you!!!!!!!
Well done! You're well on your way -- and the later videos will revisit and reinforce many of the ideas discussed here.
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
Cheers!
Awesome tut! Thanks Mike!
Thank you for the kind words!
Excellent teaching. Very well explained. Thank you :)
Hope i can build an useful application after gaining certain level of understanding of the language.
You are most welcome! Yes, one day--keep learning each day little by little!
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.
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!
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.
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) .
@@MikeShah thanks for the clarification!
Thank you for the tutorial Professor!
You are most welcome!
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));
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!
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
Amazing tutorial! Thank you!
Cheers, thank you for the kind words!
Good stuff... thank you!
Cheers!
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?
Ideally a smart 'linker' will only bring in the symbols actually used. :)
#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)
Cheers!
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.
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.
@@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.
@@slavapavlov9473 I agree it should be a default, strange it is not on your system.
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?
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.
very very good Tutorial
Cheers!
Java? Python? C++? Hahahaha.....
C is the only programming language made for real men!
Great video, Mike!
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).
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.
True, base case should be n
So Mike I wanted to ask if you can use node_t when declaring next pointer in the struct ??
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;
};
@@MikeShah thanks 👍
from where i can learn python ? please suggest .
There will be something on this channel in a few weeks time.
28:20 italian flag 🤌
viva Italia! Good eye!
40:22 I get a 'negative number' printed out even with *%i* format specifier:
ruclips.net/video/1zBq62HNYMs/видео.html
I'm assuming your argument is still 'unsigned int' and you're passing in a negative number?
@@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.
@@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.
I like the 'CInForeverAndADay' folder :)
@@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.
I needed it man
Cheers!