Clearing screen and kbhit() function

后端 未结 2 1533

I got some problems writing my snake game program. I need to make game working on linux and windows. I found some topics how to clear screen on linux and windows using the

2条回答
  •  爱一瞬间的悲伤
    2020-12-22 09:36

    C89 does not have terminal handling functions. Instead, you should use OS specific functions. So you need to have, say, a source file only for windows functions and another for linux. Another option is to use a cross platform library. I would choose ncurses for this task:

    http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/

    It works on any unix system, including linux and Mac OS. For windows versions, see:

    Is ncurses available for windows?

    With ncurses, you have functions like erase() and clear() to clear the screen.

提交回复
热议问题