How do I make my program beep.
Richard A. O'Keefe
ok at goanna.cs.rmit.oz.au
Thu Jun 7 09:46:09 AEST 1990
In article <1990Jun6.124609.7316 at agate.berkeley.edu>, dankg at 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."
More information about the Comp.lang.c
mailing list