clrscr() and delline() functions of conio.h in C

In this article, we are going to learn about the two very useful functions clrscr() and delline() of conio.h header file in C programming language.
Submitted by Manu Jemini, on March 14, 2018

clrscr() and delline() functions of conio.h

When you are working on the console, you should always keep it clean and sober. The first thing we should do is to clear the whole console when the program starts at the beginning. To accomplish this task all you need to do is use clrscr() function at starting.

What clrscr() function does?

It removes everything from the console and we get a clean console window ready to use.

delline() function in C

When you do not want to clear the whole screen? May be, we only want to delete a single line or multiple lines. The Function delline() delete the current cursor line from the console. (Check the example given below for more clarification).

We can say delline() is an abbreviation for Delete Line. This can be very useful when you want to bring something up, because all you will need to do is raise your cursor up and delete those lines. Which in turn brings up the matter up.

conio.h - clrscr() function Example in C

#include <stdio.h>
// to use clrscr()
#include <conio.h>

int main() {
  // message on screen
  printf("To clear the screen press any key from keyboard.");

  getch();
  // to clear screen
  clrscr();

  // message after clearing the screen
  printf("The previous screen is now cleared.\n");
  printf("To get exit from the code just press any key.");

  getch();
  return 0;
}

Output

conio.h - clrscr() function Example in C

conio.h - delline() function Example in C

#include <stdio.h>
// to use delline() function
#include <conio.h>

int main() {
  // single line message
  printf("To delete this line just press any key from keyboard.");

  getch();
  // calling function
  delline();

  // print the message after the code run successfully
  printf("The line is deleted now.");

  getch();
  return 0;
}

Output

conio.h - delline() function Example in C



Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.