清除屏幕的kbhit()函数 [英] Clearing screen and kbhit() function

查看:328
本文介绍了清除屏幕的kbhit()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了一些问题写我的蛇游戏程序。我需要在Linux和Windows的游戏工作。我发现了一些主题如何使用#IFDEF车窗等等的问题是我需要使用C89标准来清除在Linux和Windows的屏幕,和IM不知道系统(CLS)是C89。你能不能帮我找到C89功能,画面清晰,并告诉我一些有关的kbhit()函数在Linux上?对不起,我的英语,并感谢帮助。

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 #ifdef Windows etc. The problem is i need to use C89 standard, and im not sure that system("cls") is in C89. Could you help me with finding C89 functions to clear screen, and tell me something about kbhit() function on linux? Sorry for my english, and thanks for help.

推荐答案

C89不具有码头装卸功能。相反,你应该使用操作系统特定的功能。所以,你需要有,说,仅适用于Windows的功能和Linux的源文件中的另一个。另一种选择是使用一个跨平台库。我会选择这个任务的ncurses:

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 /

这适用于任何UNIX系统上,包括Linux和Mac OS上。对于Windows版本,请参见:

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

可用于Windows的ncurses?

使用ncurses的,你有一个像擦除()和清晰(功能),以清除屏幕。

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

这篇关于清除屏幕的kbhit()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆