Pages

Showing posts with label clearing output window. Show all posts
Showing posts with label clearing output window. Show all posts

Wednesday, July 13, 2011

The clrscr() Function in C and C++

Function Name: clrscr()                           
Function Header: <conio.h>
Declaration:  void clrscr(void);
Return ValueNone

The clrsrc() function is used to clear text mode window. It clears the current text window and places the cursor in the upper left-hand corner (at position 1, 1). If you don’t use this function, you will see the previous output text written by previous program. 



Example of the clresc() function

#include<stdio.h>
#include <conio.h>

 void  main()
 {
    int i;
    clrscr();
    for( i = 0; i < 10; i++)
    printf("clrscr function test\n");
    printf("\n\nPress any key to clear screen");
    getch();

    clrscr();
    printf("The screen has been cleared!");
    getch();
 }


Output


When you press any key, you will find the below output.