How do I make my program beep.

Mark Harrison harrison at necssd.NEC.COM
Sat Jun 2 02:44:57 AEST 1990


In article <1990May27.000808.13551 at utzoo.uucp>,
henry at utzoo.uucp (Henry Spencer) writes:
> In article <3472 at umn-d-ub.D.UMN.EDU>
  halam2 at umn-d-ub.D.UMN.EDU (Haseen Alam) writes:

> > The K&R says that '\a' is an alert (audible bell), but how do I use it to
> > make my program beep?  All my attemps were vain!!

> On what machine?  You should ask this on a machine-specific newsgroup, like
> say comp.sys.ibm.pc.programmer.  How you get a beep is *highly* hardware-
> dependent.  My Sun-3/180 can't beep at all (although most of the terminals
> attached to it can).

I think Haseen was asking why the program

	main() { printf("hello world\a\n"); }

prints
	"hello worlda"

instead of
	"hello world" and then beeping.

The '\a' alarm sequence is a new feature.  Old fashioned compilers (read:
most Unix compilers) don't support this, but on ascii machines, you can
encode an octal seven (the "bel" character) to do the same thing:  Of
course your terminal/computer has to have the beeping hardware to make
the noise.

	main() { printf("hello world\7\n"); }
-- 
Mark Harrison             harrison at necssd.NEC.COM
(214)518-5050             {necntc, cs.utexas.edu}!necssd!harrison
standard disclaimers apply...



More information about the Comp.lang.c mailing list