In C, you have header files, denoted with the suffix .h
. Some of these are ‘built in’ and every C compiler knows how to use them. Others are packaged with libraries you install. Some are local headers you write yourself.
Overall, the purpose of a header is to let the code you have written use functions, variables, structures, ect (though mostly functions early on) that were written by someone else (or yourself!) in some other file or library.
stdio.h
is the Standard I/O header that every C compiler needs to support. This lets you use the printf
function, for example. There are a bunch of C compilers out there, like GCC, Clang, LLVM, Intel, etc, and they all know what stdio.h
includes.
It sounds like cs50.h
is a library header. Specifically, cs50.h
is part of some software that was written by the team at Harvard to include some things you need for that class. This lets you use the get_string
or get_int
functions that the Harvard team wrote.
Local headers are files that you write for your programs to let other parts of your program know about each other.
Welcome to learning C! I think it’s a great language to start with!