Calling Function of .h file in C programming. Functions are used to divide a large program into sub-programs for easy control. All these sub-programs are called sub-functions of the program.
// Goto 'File' -> 'New' -> and Select 'Text Edit' and Write the following Code
// and Save File with '.h' Extension like 'MyFile.h'.
void fun() //this is Function.
{
printf("This is Simple Function\n");
}
void fun2() //this is another Function.
{
printf("This is Another Simple Function");
}
// Write the following Code in Main Program.
#include<stdio.h>
#include<conio.h>
#include "MyFile.h" //including 'MyFile.h' File.
void main()
{
fun(); //calling 'fun()' function.
fun2(); //calling 'fun2()' function.
getch();
}
// Write the following Code in 'MyFile.h' File.
void fun() //this is function.
{
printf("This is Simple Function\n");
}
void fun2() //this is function.
{
printf("This is Another Simple Function\n");
}
// Write This Code in 'MyFile2.h' File.
void fun3() //this is function.
{
printf("This is Function of MyFile2.h File\n");
}
void fun4(int arg) //passing here argument to parameter.
{
printf("This is Parameterized Function: %d", arg);
}
// Write This Code in Main Program.
#include<stdio.h>
#include<conio.h>
#include "MyFile.h" //including 'MyFile.h' File.
#include "MyFile2.h" //including 'MyFile2.h' File.
void main()
{
fun(); //calling 'fun()' function.
fun2(); //calling 'fun2()' function.
fun3(); //calling 'fun3()' function.
fun4(54265); //calling and passing argument to parameter.
getch();
}