Path: utzoo!attcan!uunet!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!agate!tornado.Berkeley.EDU!dankg From: dankg@tornado.Berkeley.EDU (Dan KoGai) Newsgroups: comp.lang.c Subject: Re: How do I make my program beep. Summary: It's harder than we might think Keywords: beep Message-ID: <1990Jun8.170657.9102@agate.berkeley.edu> Date: 8 Jun 90 17:06:57 GMT References: <3472@umn-d-ub.D.UMN.EDU> <1990May27.000808.13551@utzoo.uucp> <1990Jun6.124609.7316@agate.berkeley.edu> <3168@goanna.cs.rmit.oz.au> <43605@ism780c.isc.com> Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: dankg@tornado.Berkeley.EDU (Dan KoGai) Organization: ucb Lines: 34 In article <43605@ism780c.isc.com> marv@ism780.UUCP (Marvin Rubenstein) writes: >>(2) #define mybeep putchar('\7') >> has a fairly serious defect: output to stdout is often buffered or >> line-buffered, and '\7' is not a complete record. You need >> #define mybeep (putchar('\7'), fflush(stdout)) >> > >putchar('\7') has an even more serious defect. The reason for beeping is >to notify the user of the program of something while the program is >*running*. There is no guarantee that sending a '\7' to stdout will cause an >beep. Stdout may well be a diskfile. The output must be directed to a >device that will make a noise that the user can hear. I know of no portable >way to do this. You are absolutely right: Even using fputc(stderr, '\7'), some shells can still put stderr to files without prob. fputc(/dev/tty, '\7') ? maybe. Still it's not very good idea to beeb via ascii beep: Such machines as Macintosh have very extensive sound package and maybe other program is using sound port alread (Mac has 4 channels though). Suppose you are plaing Loud music with CD-ROM driver and you want to beep. What you you do? Find unused soundport and beep on the background which might be ignored due to other sound? or you halt other programs, stop other sound and beep? There are many possibilities. IMHO, warning by ascii beep is obsolete technique, with machines with far more complex and capability of handling sound. ---------------- ____ __ __ + Dan The "beep("Don't Beep, man!")" Man ||__||__| + E-mail: dankg@ocf.berkeley.edu ____| ______ + Voice: +1 415-549-6111 | |__|__| + USnail: 1730 Laloma Berkeley, CA 94709 U.S.A |___ |__|__| + |____|____ + "What's the biggest U.S. export to Japan?" \_| | + "Bullshit. It makes the best fertilizer for their rice"