如何以可移植的方式验证ANSI C的stdin缓冲区中是否存在某些信息? [英] How to verify if there is some information in the stdin buffer in ANSI C in a portable way?

查看:49
本文介绍了如何以可移植的方式验证ANSI C的stdin缓冲区中是否存在某些信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在ANSI C中开发可移植函数,以验证stdin缓冲区是否为空.这个想法是用它来验证用户是否按下了某些键.

I'm trying to develop a portable function in ANSI C that verifies if the stdin buffer is empty. The idea is to use it to verify if the user has pressed some key.

在Windows中,使用kbhit(来自conio.h)很容易做到这一点,但它取决于操作系统.

In windows, it is easy to do that using kbhit (from conio.h), but it is OS dependent.

但是,我想开发自己的可移植功能.

However, I'd like to develop my own portable function.

推荐答案

ANSI C和当前的C标准都没有提供实现此目的的方法.只能使用特定于实现的扩展来完成.

Neither ANSI C nor the current C standard provides a way to do this. It can only be done using implementation-specific extensions.

这篇关于如何以可移植的方式验证ANSI C的stdin缓冲区中是否存在某些信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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