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::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 常量变量在标题中不起作用 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
