C program to create your own header file/ Create your your own header file in C
In this program, we will create our own source (.c) and header file (.h) files and access their function. We will declare associate functions in header file and write code (definition) in source files.
Create your own Header and Source File Example in C
There will be three files
- myfun.c - Source file that will contain function definitions.
- myfun.h - Header file that will contain function declaration which have definition in myfun.c source file.
- main.c – Main Source file that will contain complete code and access the functions which are declared in myfun.h header file.
myfun.h - Header file
myfun.c - Source file
main.c - Main Source file
Compiling the program
In turboc Compiler: - Just like normal program compilation, press ALT+F9 to compile and CTRL+F9 to run the program.
In gcc/g++ in Linux Compiler: To compile we can write command gcc main.c myfun.c -o main, gcc *.c -o main or gcc -o main *.c .
To Run: write command ./main
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer