Declaration & Assignments
C Custom Header File
You can create your own custom header files in C, it helps you to manage user defined methods, global variables and structures in separate file, which can be used in different modules.
Process to Create Custom Header File in C
For example, I am calling an external function named swap in my main.c file.
Example:
#include<stdio.h>
#include"swap.h"
void main()
{
int a=20;
int b=30;
swap (&a,&b);
printf ("a=%d\n", a);
printf ("b=%d\n",b);
}
Swap method is defined in swap.h file, which is used to swap two numbers by using a temporary variable.
Example:
void swap (int* a, int* b)
{
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
Note:
Comments
Post a Comment