-1

我的 Windows 控制台有问题...在 Windows api 中,控制台是否总是必须是屏幕或键盘,或者它可以是任何字符缓冲区或类似文本文件的东西?

谢谢

如果我更具体一点,Windows api 中的SetConsoleMode fnction 有一个名为hConsoleHandle的参数,它有一个名为ENABLE_ECHO_INPUT的标志,可用于将我们读到的每个字符回显到屏幕上。所以我认为在 Windows 系统编程中,控制台的含义不仅仅是这是正常的意思......我也是这样写的,如果是这样,真正的意思是什么......?

再次感谢

4

3 回答 3

1

在 Windows 下,控制台始终是一个类似于命令提示符窗口的窗口。您可以在 Windows 程序中打开和读取/写入该内容。它不是缓冲区或文本文件,但您可以编写缓冲区或文本文件,然后将该实体传输到控制台。

窗口控制台

以下是您在处理控制台窗口时可以使用的 C 语言函数:

_cgets, _cgetws, _cgets_s, _cgetws_s
 Read string from console

_cprintf, _cwprintf, _cprintf_s, _cprintf_s_l, _cwprintf_s, _cwprintf_s_l
 Write formatted data to console

_cputs
 Write string to console

_cscanf, _cwscanf, _cscanf_s, _cscanf_s_l, _cwscanf_s, _cwscanf_s_l
 Read formatted data from console

_getch, _getwch
 Read character from console

_getche, _getwche
 Read character from console and echo it

_inp
 Read one byte from specified I/O port

_inpd
 Read double word from specified I/O port

_inpw
 Read 2-byte word from specified I/O port

_kbhit
 Check for keystroke at console; use before attempting to read from console

_outp
 Write one byte to specified I/O port

_outpd
 Write double word to specified I/O port

_outpw
 Write word to specified I/O port

_putch, _putwch
 Write character to console

_ungetch, _ungetwch
 "Unget" last character read from console so it becomes next character read
于 2011-10-16T09:41:48.347 回答
1

不,“控制台”意味着具有基于文本的界面的应用程序。

Wikipedia 上的Win32 控制台说,该标签指定了在 Windows API 下运行的文本模式程序,并且将使用例如WriteConsole代替printfor之类的函数cout

所以,控制台是一样的,但底层库是不同的。

于 2011-10-16T09:46:43.147 回答
1

正如这里所描述的那样

Consoles manage input and output (I/O) for character-mode applications 
(applications that do not provide their own graphical user interface).

所以你有你的答案。如前所述,试着更好地解释你的背景、你的目标和你的想法,所以也许我们可以帮助你更多。

于 2011-10-16T09:49:20.347 回答