all functions in the sub.h header file now work. Call the function sub() directly. "subtraction.c" and &"/> all functions in the sub.h header file now work. Call the function sub() directly. "subtraction.c" and &">

Home  >  Article  >  Backend Development  >  How to write your own header file in C language?

How to write your own header file in C language?

PHPz
PHPzforward
2023-09-15 14:53:022043browse

How to write your own header file in C language?

Steps to write your own header file in C −

  • Enter the code and save it as "sub.h".
  • Write a main program named "subtraction.c", which −
    • contains the new header file.
    • Use "sub.h" instead of
    • All functions in the sub.h header file now work.
    • Call function sub() directly.
    • "subtraction.c" and "sub.h" should be in the 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 output

Subtraction of two numbers is: 1

for −

The above is the detailed content of How to write your own header file in C language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete