Can we use the below piece of code in c if we've to replace clrscr() function with an user-defined or custom function?
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
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/