为什么要使用 conio.h?

Why use conio.h?(为什么要使用 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 中的函数形成对比,其中包含 printfscanfgetchar 等函数控制台正在使用中.

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?

基础教程推荐