Why are some functions defined in more than one header file? Like malloc() is defined in malloc.h and alloc.h. And exit(0) is defined in process.h and stdlib.h,why? REPLY ASAP.
Same reason Merriam-Webster has a lot of the same words as the Oxford English dictionary. Maybe it's a waste, maybe not.
Shabbir ,your answer didn't solve my problem.Because I didn't understand the meaning of semantic help. Plz ,can you explain this ?
A function may be related to 2 operations. Say stdlib have functions for standard library function and say function x is classified as standard library function and so its there in the header file but again the same function may also be classified as memory / IO or any other utility function and so its included in the other file as well. Just a semantic help.
Thats the answer what shabbir said, to put it in simpler words. A header file is a collection of functions grouped together for a specific task or process, thus all functions in a header file are relative to each other in some context. Now a function such as exit() or malloc() can have very different applications depending on the needs of a program. For example if you need to use function exit() in your program just to exit then there will be no need of including other 59 functions defined in stdlib.h so they included the exit function in both header files. Process.h is sufficient for dealing with process abortion and ending. while stdlib.h exit function acts the same, but that file would be included when performing some standard i/o operations. To sum up , they are grouping the functions so that relativity is maintained , and multiple declarations of more generic functions define that user dont have to include all the other unnecessary functions . I hope that solved your problem, Greetings.