Article View: alt.msdos.programmer
Article #1167Re: Two C problems
From: Cameron Foster
Date: Sun, 07 Jan 1996 19:48
Date: Sun, 07 Jan 1996 19:48
53 lines
1691 bytes
1691 bytes
In <4cojnn$rgd@lugb.latrobe.edu.au> csigjb@luxor.latrobe.edu.au ()
writes:
>
>I have two C problems.
>
>PROBLEM 1 :
>
Didn't have time to look at problem 1 yet, but as to problem 2:
>PROBLEM 2 :
>
>const escape=27;
>const cr=13;
>const bs=8;
>
>while (ch!=cr)
>{
> .
> .
> .
>}
>
>while (ch!=escape)
>{
> .
> .
> .
>}
>
>If I replace the 27 with \27' or the 13 with '\13' then these loops
don't
>work i.e. an infinite loop results. WHY?
>
>Also if I want to do somthing like this : puts("\24 \25"); which
should
>print the up and down arrows on the screen (ASCII 24 and 25), but no,
it
>prints some other ASCII characters. As far as I can tell C has its own
>unique character table, at least for the control characters. WHY?
>
>Sometimes I wonder whether some one needs to go back an rewrite the
damn
>language so that it works sensibly and predictably like Pascal can be
>relied upon to do.
Actually, the "damn language" IS working sensibly and predictably! Read
up on C escape sequences.
int i = 27; /* i has the decimal value of 27 */
int i = \27; /* i has the decimal value of 23 (\27 is the octal */
/* representation of decimal 23) */
int i = \x27 /* i has the decimal value of 39 */
Technical Details
Message-ID:
<4cp82k$gsq@cloner3.netcom.com>Path:
arc1-ca.pugleaf.net!ix.netcom.com!netnewsReferences:
<4cojnn$rgd@lugb.latrobe.edu.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!ix.netcom.com!netnews From: cfoster1@ix.netcom.com(Cameron Foster ) Newsgroups: alt.msdos.programmer,comp.lang.c Subject: Re: Two C problems Date: 7 Jan 1996 19:48:36 GMT Organization: Netcom Message-ID: <4cp82k$gsq@cloner3.netcom.com> References: <4cojnn$rgd@lugb.latrobe.edu.au> NNTP-Posting-Host: ple-ca6-01.ix.netcom.com X-NETCOM-Date: Sun Jan 07 11:48:40 AM PST 1996