Turn Desktop View Off
You are here:   HomeC Programming (Theory)Basic Of C Prog.Write a C program to use getchar() in for loop.
by Dinesh Thakur Category: Basic Of C Programming

The main role of header file is it is used to share information among various files.To put it brief, if we have several functions say 4 functions named as f1, f2, f3, f4 placed in file say sample.c and if all the functions want to get accessed each other all must be placed in the same file sample.c. 

 In other words if there is a function say F5 placed in another file say example.c and if the function F1 placed in sample.c wants to access the function F5 placed in example1.c it is not possible. For this what we can do is add the function definition in the main program from which the function is going to get called. But this will make the process tiring if the program has lot of functions because if there is a change in arguments in functions each time programmer has to search for the function definition file and has to make change in the function definition file as well as in the actual function. These will make the process tiring.

To avoid all this and to make the process simple what one can do is have a header file and place the function declarations in a header file say for instance if the header file is sample.h where function declarations area made the programmer ahs to include this header file in the source file where the functions are used as

 

#include sample.h

 

In this way of there is any modification in function arguments only eth actual function and the definitions defined in the single place namely header file has to be changed.





Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular





Popular Article