ESC密钥如何与ANSI C程序交互? [英] How does ESC key interact with ANSI C programs?

查看:64
本文介绍了ESC密钥如何与ANSI C程序交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hugo27 2004年7月13日


我读过的教学书籍和文档并没有提到Escape键,但每次我在
运行时我的程序去香蕉。

这涉及到一个更大的问题,即什么是标准C适合的?它的用途是什么?
我们有空集:每个人都写和
使用他们自己的程序。这在一定程度上起作用,但它对一个小世界起了作用。当你冒险进入更大的世界并与其他人(又名Damm Thing)见面时会发生什么?
假设一个人为一个
雇主写了一个共同的菜单程序有人按时退出ESC,
程序崩溃,客户想要他们的钱回来?你是否要告诉法官
投诉是关闭主题?

在ANSI C中是否有办法禁用或管理Escape键?我已经尝试用scanf和getchar捕获ascii 27
但是它驱动程序
batty。

感谢您的想法。
hugo


解决方案

[新手回答]

hugo27写道:

ANSI中是否有办法C禁用或管理退出键?




我猜不会。


A微波炉可能有用ANSI C编写的程序。

手机可能有用ANSI C编写的程序。

电子秒表可以用ANSI C编写的程序。 />
....


所有这些东西中的Escape键在哪里? :-)


-

如果每个人都读到USENET将是一个更好的地方:给我发电子邮件:使用|
http:/ /www.catb.org/~esr/faqs/smart-questions.html |我的名字在收件人:中|
http://www.netmeister.org/news/learn2quote2 .html |标题,textonly |
http://www.expita.com/nomime。 HTML |没有附件。 |




" hugo27" < OB **** @ yahoo.com>在消息中写道

新闻:a7 ************************** @ posting.google.c om ...

hugo27 2004年7月13日


我读过的教学书籍和文档并没有提到Escape键,但每次我点击在
运行期间,我的程序会变成香蕉。

这涉及到一个更大的问题,即什么是标准C适合的?它的用途是什么?
我们有空集:每个人都写和
使用他们自己的程序。这在一定程度上起作用,但它对一个小世界起了作用。当你冒险进入更大的世界并与其他人(又名Damm Thing)见面时会发生什么?
假设一个人为一个
雇主写了一个共同的菜单程序有人按时退出ESC,
程序崩溃,客户想要他们的钱回来?你是否要告诉法官
投诉是关闭主题?

在ANSI C中是否有办法禁用或管理Escape键?


不,因为ANSI(正式的ISO)C没有定义

这样的东西作为''键'',''键盘'',或任何硬件

设备。所有的i / o都被抽象为''
字符'的流'。

我试过捕获ascii 27




ASCII字符集确实定义了一个值为27的

助记符''ESC'',但这并不一定是
对应于PC键盘的''''''''''''''$ $ $ $
生成的键盘''''''$ $
C语言不需要使用ASCII字符
设定。它允许任何字符集包含标准所需的最小值字符集。这些字符的实际编码

留给实现。他们都没有

被称为''逃避''。

with scanf和getchar,但它驱动程序
batty。




在典型的PC上,scanf()和getchar()都不会看到

任何输入来自ESC键。从C''si / o库的角度来看,它不会产生''字符'




你需要使用图书馆的''扩展名''(如果您的实施

提供一个),或者可能是第三方图书馆。


你想要的是什么确实需要与您的操作系统和/或硬件进行直接通信,这两种情况都不是ISO C支持的b $ b。


例如如果您使用的是Windows系统,请尝试 www.msdn.microsoft.com


-Mike




" Pedro Graca" <他**** @ hotpop.com>在消息中写道

news:sl ******************* @ ID-203069.user.uni-berlin.de ...

[新手答案]
hugo27写道:

在ANSI C中是否有办法禁用或管理退出键?



我想没有。

微波炉可能有用ANSI C编写的程序。
手机可能有用ANSI C编写的程序。电子秒表可以用ANSI C编写程序。


所有这些东西中的Escape键在哪里? : - )




监狱安全控制系统可以用C语言编写。

硬件可能没有逃生钥匙。 :-)


-Mike


hugo27 July 13, 2004


The teachy books and documentation I''ve read do not
mention the Escape key, but everytime I hit it during
runtime my programs go bananas.

This relates to a larger issue, namely, what is
standard C good for? Of what use is it?
We have the null set: each person writes and
uses their own progams. This works to a degree, but
it makes for a small world. What happens when you
venture into the larger world and meet up with
Other People (aka, The Damm Thing)?
Suppose one writes a common menu program for an
employer and someone sonetime presses ESC, the
program crashes, and the client wants their money
back? Are you going to tell the judge that the
complaint is Off Topic?

Is there a way in ANSI C to disable or manage
the Escape key? I''ve tried capturing ascii 27
with scanf and getchar, but it drives the program
batty.

Thanks for your thoughts.
hugo


解决方案

[newbie answer]
hugo27 wrote:

Is there a way in ANSI C to disable or manage
the Escape key?



I guess there isn''t.

A microwave oven could have programs written in ANSI C.
A mobile phone could have programs written in ANSI C.
A electronic stopwatch could have programs written in ANSI C.
....

Where is the Escape key in all these things? :-)

--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |



"hugo27" <ob****@yahoo.com> wrote in message
news:a7**************************@posting.google.c om...

hugo27 July 13, 2004


The teachy books and documentation I''ve read do not
mention the Escape key, but everytime I hit it during
runtime my programs go bananas.

This relates to a larger issue, namely, what is
standard C good for? Of what use is it?
We have the null set: each person writes and
uses their own progams. This works to a degree, but
it makes for a small world. What happens when you
venture into the larger world and meet up with
Other People (aka, The Damm Thing)?
Suppose one writes a common menu program for an
employer and someone sonetime presses ESC, the
program crashes, and the client wants their money
back? Are you going to tell the judge that the
complaint is Off Topic?

Is there a way in ANSI C to disable or manage
the Escape key?
No, because ANSI (formally "ISO") C does not define
such a thing as a ''key'', a ''keyboard'', or any hardware
devices at all. All i/o is abstracted as ''streams of
characters''.

I''ve tried capturing ascii 27



The ASCII character set does define a value 27 with
the mnemonic ''ESC'', but that doesn''t necessarily
correspond to what a PC keyboard''s ''escape'' key
generates.

The C language does not require using the ASCII character
set. It allows any character set which contains the mimimum
set of characters required by the standard. The actual encodings
of these characters is left to the implementation. None of them
is called ''escape''.
with scanf and getchar, but it drives the program
batty.



On a typical PC, neither ''scanf()'' nor ''getchar()'' will ''see''
any input from the ''ESC'' key. It doesn''t generate a ''character''
from the perspective of C''s i/o library.

You''ll need to use a library ''extension'' (if your implementation
provides one), or perhaps a third party library.

What you''re trying to do involves direct communication with
your operating system and/or hardware, neither of which is
supported by ISO C.

E.g. if you''re working with a Windows system, try www.msdn.microsoft.com

-Mike



"Pedro Graca" <he****@hotpop.com> wrote in message
news:sl*******************@ID-203069.user.uni-berlin.de...

[newbie answer]
hugo27 wrote:

Is there a way in ANSI C to disable or manage
the Escape key?



I guess there isn''t.

A microwave oven could have programs written in ANSI C.
A mobile phone could have programs written in ANSI C.
A electronic stopwatch could have programs written in ANSI C.
...

Where is the Escape key in all these things? :-)



Prison security control systems could be written in C.
The hardware probably won''t have an escape key. :-)

-Mike


这篇关于ESC密钥如何与ANSI C程序交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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