Path: utzoo!attcan!uunet!munnari.oz.au!bruce!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: How do I make my program beep. Keywords: beep Message-ID: <3168@goanna.cs.rmit.oz.au> Date: 6 Jun 90 23:46:09 GMT References: <3472@umn-d-ub.D.UMN.EDU> <1990May27.000808.13551@utzoo.uucp> <1990Jun6.124609.7316@agate.berkeley.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 20 In article <1990Jun6.124609.7316@agate.berkeley.edu>, dankg@tornado.Berkeley.EDU (Dan KoGai) writes: > /* #ifdef UNIX */ > #define RETURN '\n' /* for portability. \r for Macintosh, et al */ > #define mybeep beep() putchar(\07) /* Also for portability */ > /* endif */ (1) Isn't \n supposed to be mapped to whatever the local end of line convention is? Is it legal for a Mac C compiler to map \n to anything other than CR, or to something which will have the same effect when output? (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)) (3) This is better as a function than a macro anyway. -- "A 7th class of programs, correct in every way, is believed to exist by a few computer scientists. However, no example could be found to include here."