Function clrscr in C and C++

前端 未结 5 961
鱼传尺愫
鱼传尺愫 2020-12-03 18:43

Does today\'s C or C++ compilers use the clrscr system function?

5条回答
  •  一个人的身影
    2020-12-03 19:39

    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 . 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.

提交回复
热议问题