please explain... thanks
Printable View
please explain... thanks
A header is just one file containing definitions and such whereas a library is a collection of header files and source files that ultimately provide a useful framework. For example, a data structure library could contain headers and source files that implement common data structures like trees, lists, etc. This library could then be used to produce useful programs faster (by reducing the time it takes to code those things provided in the library).
ok... but this means C programming language has one library? C standard library - Wikipedia, the free encyclopedia or? who are other types of libraries of C
Yes, C standard library refers to all the functionality provided as part of the standard. You can search Google for other libraries. There are all sorts of libraries for developing GUIs, for scientific and mathematical computation, etc.
I believe a header should include:
#includes needed for that specific header
#defines and macros
constants
structs
enums
function declarations (not definitions)
Function declarations belong in a file of the same name as the header, but with a .c extension. Also the program should be compiled separately and linked together later. Correct me if I am wrong...
Not a requirement. .Quote:
Function declarations belong in a file of the same name as the header, but with a .c extension
Not required, but good practice.
More on headers:
Header Files - The C Preprocessor
Header files are just C source (text) files containing function prototypes, defines, compiler directives. They are #included in your source files as needed. Usually have extension .h Libraries are already compiled objects (code) which are linked together with your code. Extension .lib. Standard library is implied without any additional fuss but if you wish to incorporate other external libraries the "environment" must be told to include them. Or they are named in make files.
To understand the difference between header and library; it helps to know the difference between Compiler and Linker. The two areas really go together.
Tim S.