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.hprovide, what the functions of the standard C libraries can't? - Why to choose the
coniolibrary?
推荐答案
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?
基础教程推荐
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- c++ STL设置差异 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
