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 it is to be used, then it should be placed 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 program

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 for

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.