English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
There are several methods to clear the console or output screen, one of which isclrscr()
Method. When the function is called, it clears the screen. It is declared in the 'conio.h' header file. There are also other methods, such as system('cls') and system('clear'), which are declared in the 'stdlib.h' header file.
This is the syntax for clearing the C language console
clrscr(); OR system("cls"); OR system("clear");
This is an example of clearing the C language console
Suppose we have a 'new.txt' file with the following content-
0,hell!o 1,hello! 2,gfdtrhtrhrt 3,demo
Now, let's look at an example.
#include<stdio.h> #include<conio.h> void main() { FILE *f; char s; clrscr(); f=fopen("new.txt","r"); while((s=fgetc(f))!=EOF) { printf("%c", s); } fclose(f); getch(); }
Output Result
0,hell!o 1,hello! 2,gfdtrhtrhrt 3,demo
In the above program, we have a text file 'new.txt'. The file pointer is used to open and read the file. It is displaying the content of the file. To clear the console, pleaseclrscr()
Use.
clrscr(); f=fopen("new.txt","r"); while((s=fgetc(f))!=EOF) { printf("%c", s); }