Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!brl-tgr!tgr!Purtill@MIT-MULTICS.ARPA From: Purtill@MIT-MULTICS.ARPA (Mark Purtill) Newsgroups: net.lang.c Subject: Re: CTRL(X) in ANSI standard Message-ID: <10590@brl-tgr.ARPA> Date: Fri, 10-May-85 21:16:19 EDT Article-I.D.: brl-tgr.10590 Posted: Fri May 10 21:16:19 1985 Date-Received: Sun, 12-May-85 02:30:34 EDT Sender: news@brl-tgr.ARPA Lines: 45 > >> [use '\^X' instead of CTRL(x) or CTRL('x')] > > As has been said before, the right way to do this is: > > #define BEL '\007' > I was thinking mainly about programs that use curses or otherwise read > characters one at a time and do special things with ctrl chars. E.g., Actually, that's no problem. You just say #define UP_CHAR '\025' #define DOWN_CHAR '\004' ... switch( c) { case UP_CHAR: ... Case DOWN_CHAR: ... ... } This is actually BETTER, since you don't have magic numbers in the code. > using >printf("\^T%c%c", row, col) is a bit more obvious than >printf("\024%c%c", row, col). This brings up a real problem: if you have a magic CHARACTER, you can't use it in a STRING. Under ANSI C, at least you can get by with #define MAGIC_CHAR '\024' #define MAGIC_CHAR_STRING "\024" and then say printf( MAGIC_CHAR_STRING "%c%c", row, col) ; but that's not really satisfactory. (It *is* better that printf( "%c%c%c", MAGIC_CHAR,...) ; or printf( "\666%c%c",...) ; tho.) How about making a string adjacent to a character constant absorb said character constant? Then "foo" '\001' => "foo\001", and '\001' "foo" => "\001foo", just as in the standard, "foo" "\001" => "foo\001". Then printf( MAGIC_CHAR "%c%c",...) ; works like one would like. Mark ^.-.^ Purtill at MIT-MULTICS.ARPA **Insert favorite disclaimer here** ((")) 2-032 MIT Cambrige MA 02139