please explain... thanks
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).
1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.
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.
1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.
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. .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.
1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.