Assuming that I have 3 source files for an exe in C. Is it a good practice to include headers like stdio in all the three and also in the source file which contains the main() function?
If NO then what is the normal practice.
I read an article which says the header should contain all the definitions of the structures, #defines etc. But I not sure about including other standard headers.
Any suggestions is appreciated!
Include only headers, you need. And no others.
Including additional headers, that are not necessary, may/will produce unnecessary larger exe/lib. You don’t need that.
Also, this could be misleading for somebody – don’t include code, that you don’t need.
It could cause name conflicts, for example – if you include headers, containing functions, with the same name. You don’t need this, too.
Cdoes not havenamespaces, so you don’t need to include names, you will not use. You may want to use them for other things.If you need a header in several modules – include it. Otherwise: