为什么要使用conio.h? [英] Why use conio.h?

查看:56
本文介绍了为什么要使用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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆