Showing posts with label Custom clrscr in C. Show all posts
Showing posts with label Custom clrscr in C. Show all posts

Thursday, November 5, 2020

Custom Clear Screen using C Program

 /*

  *****************************************************

    CUSTOM CLRSCR() function

    Clear the Screen using HORIZONTAL & VERTICAL wise

  *****************************************************

*/

#include <stdio.h>

#include <conio.h>

#include <dos.h>

void main(){

  int i,j;

  /* ------------------------------ */

  /* Message about Horizontal Clear */

  /* ------------------------------ */

     /* Fill the screen with @ symbol */

     for (i=1; i<=80;i++){

      for (j=1; j<=25; j++){

printf("@");

      }

    }


     gotoxy(20,13);

     textcolor(9);

     cprintf("Custom CLRSCR using HORIZONTAL !");

    /* Perform custom clrscr() by clearing in HORIZONTAL */

    for (j=1; j<=25; j++){

     for (i=1; i<=80;i++){

gotoxy(i,j); /* COLUMN, ROW */

printf(" ");

delay(2);

      }

    }

    /* ------------------------------ */

  /* Message about Vertical Clear */

  /* ------------------------------ */

     /* Fill the screen with @ symbol */

     for (i=1; i<=80;i++){

      for (j=1; j<=25; j++){

printf("@");

      }

    }

     gotoxy(20,13);

     textcolor(9);

     cprintf("Custom CLRSCR using Vertical !");

    /* Perform custom clrscr() by clearing in Vertical */

    for (i=1; i<=80;i++){

    for (j=1; j<=25; j++){

gotoxy(i,j); /* COLUMN, ROW */

printf(" ");

delay(2);

      }

    }

   getch();

}






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.

Popular Posts