[comp.lang.c] escape sequences

fjs@nntp-server.caltech.edu (Fernando J. Selman) (01/26/91)

Is there a way to conver the string (e.g.) "\a" to
the constant '\a' at run time, without writing my
own lookup table? Thank you,
				- Fernando

gwyn@smoke.brl.mil (Doug Gwyn) (01/27/91)

In article <1991Jan26.080726.21670@nntp-server.caltech.edu> fjs@nntp-server.caltech.edu (Fernando J. Selman) writes:
>Is there a way to conver the string (e.g.) "\a" to
>the constant '\a' at run time, without writing my
>own lookup table?

Judging from the "Subject:" line, what you are actually after is a
way to convert a string such as "\\a" to the character '\a'.  Since
this amounts to a part of the normal job of compilation, but you
want instead to defer the action to run time, the answer is that
there is no simple way to do this.  Use of a lookup table is
probably the easiest method.

exnirad@brolga.cc.uq.oz.au (Nirad Sharma) (01/27/91)

gwyn@smoke.brl.mil (Doug Gwyn) writes:

>In article <1991Jan26.080726.21670@nntp-server.caltech.edu> fjs@nntp-server.caltech.edu (Fernando J. Selman) writes:
>>Is there a way to conver the string (e.g.) "\a" to
>>the constant '\a' at run time, without writing my
>>own lookup table?

>Judging from the "Subject:" line, what you are actually after is a
>way to convert a string such as "\\a" to the character '\a'.  Since
>this amounts to a part of the normal job of compilation, but you
>want instead to defer the action to run time, the answer is that
>there is no simple way to do this.  Use of a lookup table is
>probably the easiest method.

What about sprintf ?

Nirad Sharma
Continuing Education Unit
The University of QUeensland
AUSTRALIA

marwk@levels.sait.edu.au (01/28/91)

In article <1991Jan26.080726.21670@nntp-server.caltech.edu>, fjs@nntp-server.caltech.edu (Fernando J. Selman) writes:
> Is there a way to conver the string (e.g.) "\a" to
> the constant '\a' at run time, without writing my
> own lookup table? Thank you,
>                               - Fernando

I hope this is what your question requires as an answer.  It seems a bit
simple to solve, so maybe I don't understand what you mean.

char s = "\a";  /* a single character string */
char c;         /* a character storage var   */

c = *s;         /* convert the string character to a single character */

Ray

--
University of South Australia    | Plus ca change, plus c'est la meme chose.
P.O. Box 1                       | Ghing thien me how, ming thien gung me how.
Ingle Farm                       |
South Australia                  |

fjs@nntp-server.caltech.edu (Fernando J. Selman) (01/28/91)

errata: I said "\a". I should have said "\\a".

gwyn@smoke.brl.mil (Doug Gwyn) (01/28/91)

In article <1991Jan27.053717.4772@brolga.cc.uq.oz.au> exnirad@brolga.cc.uq.oz.au (Nirad Sharma) writes:
>>way to convert a string such as "\\a" to the character '\a'.
>What about sprintf ?

Bzzzt!  Nope, but thanks for playing.

dave@tygra.UUCP (David Conrad) (01/28/91)

In article <1991Jan28.033219.376@nntp-server.caltech.edu> fjs@nntp-server.caltech.edu (Fernando J. Selman) writes:
>errata: I said "\a". I should have said "\\a".

Erratum: You said "errata".  You should have said "erratum".
-- 
=  CAT-TALK Conferencing Network, Computer Conferencing and File Archive  =
-  1-313-343-0800, 300/1200/2400/9600 baud, 8/N/1. New users use 'new'    - 
=  as a login id.  AVAILABLE VIA PC-PURSUIT!!! (City code "MIDET")        =
   E-MAIL Address: dave@DDMI.COM

mcdaniel@adi.com (Tim McDaniel) (01/29/91)

dave@tygra.UUCP (David Conrad) writes:
>fjs@nntp-server.caltech.edu (Fernando J. Selman) writes:
>> errata: I said "\a". I should have said "\\a".
> Erratum: You said "errata".  You should have said "erratum".

Erratum: You wrote "said".  You should have written "wrote".

(Or should it have been "typed"?)

--
Tim McDaniel                 Applied Dynamics Int'l.; Ann Arbor, Michigan, USA
Work phone: +1 313 973 1300                        Home phone: +1 313 677 4386
Internet: mcdaniel@adi.com                UUCP: {uunet,sharkey}!amara!mcdaniel

fjs@nntp-server.caltech.edu (Fernando J. Selman) (01/29/91)

dave@tygra.UUCP (David Conrad) writes:

>Erratum: You said "errata".  You should have said "erratum".
>-- 
>=  CAT-TALK Conferencing Network, Computer Conferencing and File Archive  =
>-  1-313-343-0800, 300/1200/2400/9600 baud, 8/N/1. New users use 'new'    - 
>=  as a login id.  AVAILABLE VIA PC-PURSUIT!!! (City code "MIDET")        =
>   E-MAIL Address: dave@DDMI.COM

volpe@camelback.crd.ge.com (Christopher R Volpe) (01/30/91)

In article <MCDANIEL.91Jan28125516@dolphin.adi.com>, mcdaniel@adi.com
(Tim McDaniel) writes:
|>Erratum: You wrote "said".  You should have written "wrote".

Erratum: You wrote, "You wrote 'said'. You should have written 'wrote'."  You
   should have written, "You wrote, 'said.' You should have written, 'wrote.'"

(I.e., commas precede quotations, and periods are enclosed within the
 quotation when the quotation ends the sentence.)

Followups to alt.grammar.flame

|>--
|>Tim McDaniel                 Applied Dynamics Int'l.; Ann Arbor,
Michigan, USA
|>Work phone: +1 313 973 1300                        Home phone: +1 313
677 4386
|>Internet: mcdaniel@adi.com                UUCP:
{uunet,sharkey}!amara!mcdaniel
              
==================
Chris Volpe
G.E. Corporate R&D
volpecr@crd.ge.com