问题描述
大家好,
现在让我们看看吧。这个问题是关于ANSI C ++的功能。我想要用ANSI C ++编写和编译代码,在编译时,将会发出电脑扬声器的声音。或者,至少,应该让计算机发出哔哔声。我知道计算机扬声器是否真的发出哔哔声b / b
在很大程度上取决于我正在使用的操作系统。但我并不是那么关心(在这个阶段)。我只想知道ANSI C ++
是否提供此功能。我只对ANSI C ++感兴趣,并且在标准化或非标准C ++之前,不是C ++ b而不是C ++。我不想知道大会或其他编程语言中的变通方法 -
这严格来说是一个ANSI C ++问题。
非常感谢任何帮助。
干杯,
Deets
没有严格的C ++标准API来制作和发出哔哔声。
这是特定于平台的,你可能需要使用或创建一个
兼容性库,以便携式执行此操作跨越所有平台。
提示 - GUI通常有这样做的方式。
我不知道你是哪个编译器重新使用但我的Borland 5.5 Standard
版编译器,从工具下拉菜单中选择''Environment
Options'',Preferences选项卡,我可以选择编译选项为Beep on
完成。
JB
您可以获得最接近标准C ++或标准C的
重要的是,将''\ a''转义序列发送到标准输出,
stdout stream或cout对象。
C ++标准从C继承了它,并且由于它不提供
不同的定义,它继承了C标准中的一个:
" ; \ a(警报)在不更改
活动位置的情况下生成声音或可见警报。
在大多数常见桌面系统上,它会生成从扬声器发出哔哔声,
假设电脑有一个。
-
Jack Klein
主页:
常见问题解答
comp.lang.c
comp.lang.c ++
alt.comp.lang.learn.c-c ++
Hi everyone,
Let''s see, now. This question is about the capabilities of ANSI C++. I
want to write and compile code in ANSI C++ that, when compiled, will
make the computer speaker beep; or, at least, SHOULD make the computer
speaker beep. I know that whether the computer speaker actually beeps
or not is largely dependent on the OS I''m using. But I''m not so much
concerned about that (at this stage). I just want to know if ANSI C++
provides for this functionality. I''m only interested in ANSI C++, and
not C++ prior to standardization or non-standard C++. I don''t want to
know about workarounds in Assembly or another programming language -
this is strictly an ANSI C++ question.
Any help greatly appreciated.
Cheers,
Deets
There is NO strictly C++ standard API to make and audible beep.
This is platform specific and you may need to use or create a
compatability library to perform this "portably" across all platforms.
Hint - GUI''s usually have somw way of doing this.
I don''t know which compiler you''re using but with my Borland 5.5 Standard
Edition compiler, From the tools drop down menu, I select ''Environment
Options'', Preferences tab, and I can select the compiler option to "Beep on
completion".
JB
The closest you can get in standard C++, or standard C either for that
matter, is to send the ''\a'' escape sequence to the standard output,
either the stdout stream or the cout object.
The C++ standard inherits this from C, and since it does not supply a
different definition it inherits the one from the C standard:
"\a (alert) Produces an audible or visible alert without changing the
active position."
On most common desktop systems, it produces a beep from the speaker,
assuming the computer has one.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
这篇关于让电脑扬声器发出哔哔声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!