Does today's C or C++ compilers use the clrscr
system function?
clrscr()
is a nonstandard function (neither mentioned in ISO C99
nor in ISO C++-98
) defined in <conio.h>
(which is not standard compliant itself). However some compilers (like Turbo C/C++) support it as an extension.
Like all of the stuff in conio.h
. clrscr()
has nothing to do with standard C. conio
is a common API of ancient DOS-based C implementations for lower-level console io - things like clearing the screen, moving the cursor, reading individual keystrokes, etc. I don't know the history but presumably it dates back to before DOS had ANSI.SYS
to support standard terminal-escape codes for cursor positioning, clearing the screen, changing colors, ...
If you're just playing around learning C, there's no harm in using the conio
functions, but you should avoid making a habit of #include <conio.h>
. In most of the questions I've seen on SO where conio.h
was included, it wasn't even being used... This kind of bad habit leads to senselessly nonportable code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With