-
Modifying stdio.h
after creating a function, is it possible to put it in the stdio.h library or is it better to create a diferent library of functions ?
(eg stdio2.h wich will be the modified stdio.h)
i am kinda new programming, i am far from doing stuff like this, but i am just curious.
Thnx in advance !
-
Never modify anything which comes with the compiler.
If you've got something useful you want to reuse, create your own header and library files
-
stdio.h
so is it ok to say:
#include <stdio.h>
#include <custom.h>
-
-
> or is it better to create a diferent library of functions ?
Could we see what you plan on putting in the header file?
You may want to just put your reusable code in a source file, and just link it to the rest of your program.
Lets see what you plan on putting in your actual custom.h file first though.
If you need help on other stuff, we can give a general explanation.
-
Shadow
i dont intend to modify anything at this point. because i know functions are sort of like sub-programs, and cound be used over and over, i was curious if they could be put in a "custom" library to be re-used in other programs i write (well, the programs i one day wish to be able to write) :)
-
Actually, this is exactly what I do. I group the functions by type an store them in appropriately named custom headers.
-
>>i dont intend to modify anything at this point. because i know functions are sort of like sub- programs, and cound be used over and over, i was curious if they could be put in a "custom" library to be re-used in other programs i write (well, the programs i one day wish to be able to write<<
With any non-trivial program it is always good to keep your main code as small as possible. You should just then call in functions from another file.
Example:
Code:
#include <stdio.h>
#include "common.h" /* commonly used routines */
#include "insertionsort.h"/* list operations and insertion sort function */
-
I NEED to say something!
first off: it depends on the compiler if you are allowed to do this.
Some compilers actually read the Standard headerfiles for the prototypes and actually get the rest from object files. (some compilers)
otherwise you should be able to however, I am going to strongly request that you do not.
-
You can store your function bodies in headers. I usually do that. After all, I use the compiler's IDE, not the command-line.
-
You can modify compiler headers if there is a bug in them. Comment out the bad info, and tell _why_ and _when_ the change was made.
Otherwise, if you want to have a custom set of reusable functions, create your on library and matching headerfile. Put them in their own directory in the compiler's path.
Never put sourcecode in a headerfile, unless it is a macro. Sourcecode _always_ belongs in '.c' files. Headers are for the Linker's use, to satisfy symbol-table address and references.