Substitute for getch(), gotoxy(), delay(), clrscr()

前端 未结 3 668
终归单人心
终归单人心 2021-01-13 07:48

I have some old program source code that I wrote for Turbo C compiler.I made changes to them and want to recompile them in newer compilers for Linux and Windows.So please te

3条回答
  •  囚心锁ツ
    2021-01-13 08:21

    For Windows systems:

    Best is to compile the program as a console application for windows.

    You can directly use the Windows API for console windows and console output. Take a look at the MSDN: Windows Console functions

    Here are possible replacements for the given functions:

    • getch(): use _getch() from conio.h
    • delay()/sleep(): use the windows Sleep() function
    • clrscr(): write your own clrscr() function by using FillConsoleOutputCharacter() and FillConsoleOutputAttribute()
    • gotoxy(): use SetConsoleCursorPosition()

提交回复
热议问题