Why use conio.h?(为什么要使用 conio.h?)
问题描述
我经常看到人们在 C 和 C++ 中使用 conio.h
的头文件,虽然我看不出使用 conio.h
与标准库函数相比.conio.h
还存在依赖于 Windows/MS-DOS 环境且不属于 C 标准的缺点.
I often see people use the header file of conio.h
in C and C++, although I can´t see any major benefits in use of the functions inside of conio.h
in comparison to the standard library functions. conio.h
has furthermore the disadvantages of being dependent on the Windows/MS-DOS environment and not being part of the C standard.
- 选择
conio.h
的功能的原因是什么? conio.h
里面的函数提供了什么,标准C库的函数不能提供什么?- 为什么选择
conio
库?
- What is the reason to choose functions of
conio.h
? - What do functions inside of
conio.h
provide, what the functions of the standard C libraries can't? - Why to choose the
conio
library?
推荐答案
conio.h 头文件是 Turbo C 特有的,它比最早的 C 标准早了几年.它包含特定于 DOS 命令行的例程.这里经常使用的一个函数是 getch
,它允许一次读取一个字符而无需按 Enter 键.它还包含 gotoxy
允许将光标放在终端中的特定位置
The conio.h header is specific to Turbo C, which predates the earliest C standard by several years. It contains routines that are specific to the DOS command line. One function here that's frequently used is getch
, which allows reading one character at a time without having to press the Enter key. It also contains gotoxy
which allows placing the cursor at a specific location in the terminal
一般来说,像这样与终端通信的方法是非常特定于操作系统的,因此每种方法都有自己的(通常是不可移植的)方式.
Generally speaking, methods of communicating with the terminal like this are very OS specific, so each has their own (typically non-portable) way of doing it.
这与 stdio.h 中的函数形成对比,其中包含 printf
、scanf
和 getchar
等函数控制台正在使用中.
This contrasts with the functions in stdio.h which contain functions like printf
, scanf
, and getchar
which work regardless of what type of console is in use.
这篇关于为什么要使用 conio.h?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么要使用 conio.h?


基础教程推荐
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 初始化列表*参数*评估顺序 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- CString 到 char* 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01