在 <conio.h> 中使用 _getch(),对"_"的重要性

using _getch() in <conio.h>, significance on "_"

本文关键字:getch 重要性 conio lt gt      更新时间:2023-10-16

所以我正在教自己 c++,我遇到了 conio.h

而且我通常对cin.get()有问题,有时我不得不复制它以保持鞋底打开...

法典:

// ConsoleApplication2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>

int _tmain(int argc, _TCHAR* argv[])
{
    std::cout << "Hi" ;
    _getch();
    return 0;
}
"

_getch()"的"_"部分背后的意义是什么?

有关冗长且技术性的答案,请参阅此答案。 – 约阿希姆·皮勒堡

https://stackoverflow.com/a/228797/440558

根据MSDN的说法,Microsoft决定在VS2005中转向ISO C++标准。
他们弃用了 POSIX 名称(例如 getch ) 赞成 ISO 名称 ( _getch )。

您可以在 VS 中使用 POSIX 名称,方法是在第一个标头包括之前声明:

#define _CRT_NONSTDC_NO_DEPRECATE