What is Clrscr() in C?

clrscr() function clears the screen and moves the cursor to the upper-left-hand corner of the screen. It is defined in conio.h header file. This function is optional. If the function is to be used, then place it after variable and function declaration only.

This function is only available in windows systems. You wont find it in c compilers of UNIX based and Mac systems.


Prototype

void clrscr(void);

Return Type

This function returns nothing.


Example

Below is the program explains how to use clrscr in c?

// C program to illustrate clrscr()
#include<stdio.h>
#include<conio.h>
int main()
{
  clrscr();
  printf("Hello, this is \"Scholarsoul\" \n");
  return 0;
}

Output

clrscr in c

Error clrscr Should have a Prototype. How to solve it?

  • First check that you have included conio.h header file in your program.
  • If your operating system is other than windows this header file is not supported.
  • Check for the compiler documentation regarding the presence of conio.h header file.

People Also Ask

What is the use of clrscr()?

clrscr() clears the output of previously executed program from the console.

How to use clrscr in c

Include conio.h header file. Then call clsrcr() in main function or in any other user defined function.