- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write my own header file in C?
Steps to write my own header file in C −
- Type a code and save it as “sub.h”.
- Write a main program “subtraction.c” in which −
- include new header file.
- Write “sub.h” instead of <sub.h>
- All the functions in sub.h header are now ready for use.
- Directly call the function sub().
- Both “subtraction.c” and “sub.h” should be in same folder.
Sub.h
int sub(int m,int n) { return(m-n); }
subtraction.c
Example
#include<stdio.h> #include "sub.h" void main() { int a= 7, b= 6, res; res = sub(a, b); printf("Subtraction of two numbers is: %d", res); }
After running ”subtraction.c” the output will be −
Output
Subtraction of two numbers is: 1
Advertisements