Your Second Day in C (Understand .h header and .c source files) - Crash Course in C Programming

preview_player
Показать описание

►Lesson Description: In this series of lessons I provide you with a crash course in the C programming language. In this lesson I will show you the difference between a .h file, and a .c file. This will lead us into a small discussion and demonstration of how to structure a C project. We'll also be reviewing several of the topics from the first video in the playlist linked above.

00:00 Introduction
00:40 Discussion of header versus implementation files
3:40 Creating a main.c file.
4:00 The vector struct that we are creating.
5:20 The header and implementation for our math library
7:00 Sketching a vector 'Add' function.
8:45 Including files is a copy and paste by the preprocessor
10:20 Header Guards discussion and usage
11:40 Implementing the functions in our header file in our .c file.
12:40 Refactoring our 'Add' Function
15:00 const parameters
15:57 Using our Math Library
17:00 Different ways to include files
20:25 Successfully running our program.
20:53 Review of what we have done.
24:14 Review of compiling multiple files in C
26:00 Conclusion and wrap up

►Please like and subscribe to help the channel!
Рекомендации по теме
Комментарии
Автор

That is a very good video. I enjoy watching it, but I have a couple of questions. Firstly, I do not understand why he refactored the Add function. Instead of getting two values and returning a value, he changed it to return nothing and passed two references. The result will be the value of the first variable (out). It seems like not a good practice. Lastly, why doesn't he simply pass a value for the variable (in) instead of passing a reference if he is not changing its values?

werhanihoussemeddine
Автор

You're now my number one source for learning C/C++ on YouTube! Please keep it up!

joaocesarlima
Автор

This is some sort of perfection: the quality of video, the theme you uncover, screen management, sound and explanation. You're criminally underrated teacher and video maker.

viktorkomarov
Автор

The world needs more people like Mike. That’s all I can say, you made it look so easy and smooth…. Thank you so much ❤

chriskiesel
Автор

I found your channel while searching for this video, got me do your crash course course.

kevinnudel
Автор

Very Happy I found you on youtube. You are a wonderful teacher. Thank you.

dhanushs
Автор

You are not the only programmer whose lessons I follow but you are the best at all 💯, go ahead.

abdodaood
Автор

Hey Mike, thank you for the video!

To recap.
Let's say, we have our custom functions declared in custom.h

We *#include** "custom.h"* both
in custom.c (our functions are actually implemented here) and
in main.c (our functions are used here).

We don't compile .h files. Only .c files.
For instance, *gcc main.c custom.c*
The compiler glues them together and gives us one executable.

Also, remember about so-called header guards in .h files.

And be careful about data types we're passing into our functions.
To be frank, I got the gist of it but to feel more comfortable with this topic I'll be looking for more examples in my C programming journey.

slavapavlov
Автор

as always brilliant explanation thank you Mike

sallaklamhayyen
Автор

This course is the best way to learn C, thanks for the great effort .Will you add more videos in the future??

aghiadalzein
Автор

Pls make a video on
"multiple line Macros" in C. Thanks for such nice explanation...very informative and point to point explanation.

akash-tjru
Автор

Really enjoying the series Mike. Just curious, did you mean to use 'vector_h' or 'vector_t' as the typedef?

jimstorch
Автор

Hey Mike, thank you for providing this amazing courses. Do you plan to publish this C course, and Computer System course to Udyme?

Thanks

hounangogogo
Автор

hi, its a good series. no offend, but i expect indian accent... nice suprise :D

rudolfbouzek
Автор

Hello, great video. I didnt really understand whats the problem with the function having a return type. Why did you use the pointers instead?

tristan
visit shbcf.ru