Can we use the below piece of code in c if we've to replace clrscr() function with an user-defined or custom function? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Can we use the below piece of code in c if we've to replace clrscr() function with an user-defined or custom function?

https://code.sololearn.com/cxLUkD53bd2r/?ref=app

23rd Oct 2021, 2:19 AM
S Srividhya
S Srividhya - avatar
2 ответов
+ 4
Their is no such standard function available in c cpp for screen clearing . clrscr() is defined in conio.h header file which is supportable in old compiler in modern standard it will give you error . But you can use system("cls"); it will work
23rd Oct 2021, 3:51 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
There is no standard way of clearing a screen in C/C++ because there is no concept of "screen" in C/C++. The language is meant to be used to program a lot of stuff that doesn't have a screen in it. The best way to clear a screen is to make use of platform specific methods like a library for your OS's graphic api or non standard cross platform libraries for the same. P.S. If you are planning to use system () calls to use your terminal commands to clear it's screen then make sure to read the following article about " why system () is evil " before proceeding. https://www.cplusplus.com/forum/articles/11153/
23rd Oct 2021, 4:43 AM
Arsenic
Arsenic - avatar