Showing posts with label Custom Header file in C. Show all posts
Showing posts with label Custom Header file in C. Show all posts

Thursday, December 3, 2015

Custom Header File in C

Program #3

Code inside custom header file i.e. "extn.h"

/* Custom function will do the same
functionality of clrscr(); */
void extnclrscr(){
 for (int i=1;i<=25;i++){
   for (int j=1;j<=80;j++){
     printf(" ");
   }
   printf("\n");
 }
}



Code inside main c file i.e. "customcl.c"

#include<stdio.h>
#include<conio.h>
#include "extnc.h"
int main(){
  void extnclrscr(void);

  /* Calling custom clrscr() */
  extnclrscr();

  printf("Welcome to Custom clrscr() program with the help of Custom Header file!!");
  getch();
  return 0;
}



Why should I Use Custom Header file:
You can keep your custom functions in this header file and we don't need to depend on OOB functions in C library.  In case you are planning to make a large program/project using C code this header will do a vital role.  During this time you will feel this difference.

Just like some common calculation, redundant functions which is required in many places.  In that circumstance you can opt in Custom Header file.

Before link the header (extn.h) file into main (customcl.c) file.  Compile the header file once.  Why we need to compile?  It is required to compile the file.  If the header file is not compiled then main function will not able to process and run as whole file.

Popular Posts