/** working with user defined header files in C **/
for creating a user defined header file , we have to write the functions and we have to save that file with ' .h ' extension. let us see with a small example program , which helps in understanding the defining and using a user defined header files.
we are opening a c file and writing the following code
void myfun()
{
printf("\n Hi .. This is sameer and this is my blog");
}
And we are saving this file as sam.h ( .h extension is used to represent header files)
and we are opening a new file and writing the following code as given below:
#include<stdio.h>
#include"sam.h" //here we are including user defined header file.
main()
{
printf("\n This is to show user defined hearder files in c");
myfun(); //we are calling a function from user defined header
// file
getch();
}
Explanation:
A user can define not only his own functions but also his own Header Files and can use in any program just by including the user defined Header File as shown in the example program above..
for creating a user defined header file , we have to write the functions and we have to save that file with ' .h ' extension. let us see with a small example program , which helps in understanding the defining and using a user defined header files.
we are opening a c file and writing the following code
void myfun()
{
printf("\n Hi .. This is sameer and this is my blog");
}
And we are saving this file as sam.h ( .h extension is used to represent header files)
and we are opening a new file and writing the following code as given below:
#include<stdio.h>
#include"sam.h" //here we are including user defined header file.
main()
{
printf("\n This is to show user defined hearder files in c");
myfun(); //we are calling a function from user defined header
// file
getch();
}
Output:
Explanation:
A user can define not only his own functions but also his own Header Files and can use in any program just by including the user defined Header File as shown in the example program above..