Saturday, December 5, 2015

Custom program of clrscr using gotoxy

Program #4

Description:
In this program, it will clear the screen and move the cursor to position 1,1 (1st row and 1st column)

Custom Header file: i.e. "extnc.h"

/* Custom function will do the same functionality of clrscr(); with help of gotoxy() */
#include <conio.h>
void extnclrscr(){
int i,j;
 for (i=1;i<=25;i++){
   for (j=1;j<=80;j++){
     printf(" ");
   }
   printf("\n");
 }

 /* Move cursor to 1st Row and 1st Column */
 gotoxy(1,1);
}


Main C Program file: i.e. "custclr.c"

#include<conio.h>
#include "extnc.h"
int main(){

/* Clear screen */
extnclrscr();

printf("Screen Cleared !!");
getch();

return 0;
}



 
 Note: If you notice in the main function "conio.h" included.  Is it correct?  In "extnc.h" file already "conio.h" included.  Now we are including the same header file once again.  Why the c compiler accepting this?.  Yes, It is not a issue.  Header files are local scope.

No comments:

Post a Comment

Popular Posts