Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 替换getch()、gotoxy()、delay()、clrsc()_C++_C - Fatal编程技术网

C++ 替换getch()、gotoxy()、delay()、clrsc()

C++ 替换getch()、gotoxy()、delay()、clrsc(),c++,c,C++,C,我有一些为Turbo C编译器编写的旧程序源代码。我对它们进行了更改,并希望在Linux和Windows的较新编译器中重新编译它们。因此,请告诉我什么是最好的替代函数 getch(),delay()/sleep(),clrsc(), gotoxy() < C和C++ > < /P> < P>查看库,对于UNIX兼容系统。 < Windows系统>:< /P> 最好是将程序编译为windows的控制台应用程序 您可以直接将Windows API用于控制台窗口和控制台输出。 请看MSDN: 以下是给

我有一些为Turbo C编译器编写的旧程序源代码。我对它们进行了更改,并希望在Linux和Windows的较新编译器中重新编译它们。因此,请告诉我什么是最好的替代函数

getch(),delay()/sleep(),clrsc(), gotoxy()

< C和C++ > < /P> < P>查看库,对于UNIX兼容系统。

< Windows系统>:< /P> 最好是将程序编译为windows的控制台应用程序

您可以直接将Windows API用于控制台窗口和控制台输出。 请看MSDN:

以下是给定函数的可能替换:

  • getch():使用conio.h中的_getch()
  • delay()/sleep():使用windows sleep()函数
  • CLRSC():使用FillConsoleOutputCharacter()和FillConsoleOutputAttribute()编写自己的CLRSC()函数
  • gotoxy():使用setConsoleorPosition()

在类Unix系统上,可以使用VT100转义码替换CLRSC()和gotoxy()。clrsc():

std::cout
系统(“cls”)
应为
clrsc
:)执行此项工作
std::cout << "\033[2J" << std::flush;