Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #96525

Re: The assignment for today's lesson

Subject Re: The assignment for today's lesson
Newsgroups comp.lang.c
References (4 earlier) <o07d1c$1fbu$1@gioia.aioe.org> <o07d9c$331$2@dont-email.me> <o07ug8$bv6$1@gioia.aioe.org> <o0av7a$lkr$1@jstuckle.eternal-september.org> <o0b18v$r26$1@dont-email.me>
From Richard Damon <Richard@Damon-Family.org>
Message-ID <K8aWz.42259$FG2.16931@fx24.iad> (permalink)
Organization Forte - www.forteinc.com
Date 2016-11-13 22:25 -0500

Show all headers | View raw


On 11/13/16 7:42 PM, Lew Pitcher wrote:
> On Sunday November 13 2016 19:07, in comp.lang.c, "Jerry Stuckle"
> <jstucklex@attglobal.net> wrote:
>
>> On 11/12/2016 3:36 PM, Robert Spanjaard wrote:
>>> On 12-11-16 16:43, Mr. Man-wai Chang wrote:
>>>> On 12/11/2016 11:38 PM, Robert Spanjaard wrote:
>>>>>
>>>>> I can't. System reports a Clown Overflow everytime it encounters
>>>>> "trump".
>>>>>
>>>>
>>>> You are NOT doing the homework. :)
>>>
>>> Ok, ok...
>>>
>>> #include <stdio.h>
>>>
>>> int main()
>>> {
>>>    char    chewb;    /* current character being processed */
>>>    int    r2d2,    /* number of numbers */
>>>        c3po;    /* number of letters */
>>>
>>>    while ((chewb = getchar()) != EOF)
>>>       if ((chewb >= 'a' && chewb <= 'z') || (chewb >= 'A' && chewb <= 'Z'))
>>
>> Fails for non-ASCII character sets.
>>
>>>          ++c3po;
>>>       else if (chewb >= '0' && chewb <= '9')
>>
>> Fails for non-ASCII character sets.
>
> Not really.
>
> 5.2.1 Character Sets
>   3  Both the basic source and basic execution character sets shall have the
>      following members: the 26 uppercase letters of the Latin alphabet
>        A B C D E F G H I J K L M
>        N O P Q R S T U V W X Y Z
>      the 26 lowercase letters of the Latin alphabet
>        a b c d e f g h i j k l m
>        n o p q r s t u v w x y z
>      the 10 decimal digits
>        0 1 2 3 4 5 6 7 8 9
>      ...
>      In both the source and execution basic character sets, the value of each
>      character after 0 in the above list of decimal digits shall be one
>      greater than the value of the previous.
>
> Thus, the test is valid.
>
> If the environment uses an execution character set that does not guarantee
> that numerics follow in the C execution characterset standard, I would guess
> that the whole platform would induce "undefined behaviour".
>
>

One question becomes does the problem statement of 'numbers' and 
'letters' include just the standard 'Latin' characters, or since the 
message was sent as UTF-8, there is a possibility that we may need to 
detect other characters beyond those as numbers and letters, and thus 
need to use isalpha() and isdigit() after setting the appropriate locale.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

The assignment for today's lesson "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-12 19:10 +0800
  Re: The assignment for today's lesson Robert Spanjaard <spamtrap@arumes.com> - 2016-11-12 16:38 +0100
    Re: The assignment for today's lesson "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-12 23:43 +0800
      Re: The assignment for today's lesson Robert Spanjaard <spamtrap@arumes.com> - 2016-11-12 21:36 +0100
        Re: The assignment for today's lesson "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 14:30 +0800
          Re: The assignment for today's lesson Your Name <YourName@YourISP.com> - 2016-11-13 19:37 +1300
            [OT] chat "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 14:40 +0800
              Re: [OT] chat Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> - 2016-11-13 08:58 +0100
                Re: [OT] chat "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 18:46 +0800
          Re: The assignment for today's lesson Robert Spanjaard <spamtrap@arumes.com> - 2016-11-13 11:25 +0100
            Re: The assignment for today's lesson "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 18:47 +0800
        Re: New assignment/homework "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 14:32 +0800
          Re: New assignment/homework Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-13 10:05 +0000
            [OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 18:47 +0800
        Re: The assignment for today's lesson Ike Naar <ike@iceland.freeshell.org> - 2016-11-13 20:48 +0000
          Re: The assignment for today's lesson Robert Spanjaard <spamtrap@arumes.com> - 2016-11-13 22:29 +0100
            Re: The assignment for today's lesson "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-13 16:38 -0500
              Re: The assignment for today's lesson Gareth Owen <gwowen@gmail.com> - 2016-11-13 22:24 +0000
          Re: The assignment for today's lesson "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-13 16:37 -0500
            Re: The assignment for today's lesson Ike Naar <ike@iceland.freeshell.org> - 2016-11-14 09:39 +0000
        Re: The assignment for today's lesson Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-13 19:07 -0500
          Re: The assignment for today's lesson Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-11-13 19:42 -0500
            Re: The assignment for today's lesson Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-13 21:47 -0500
              Re: The assignment for today's lesson Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-11-14 10:39 -0500
                Re: The assignment for today's lesson Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-14 11:38 -0500
                Re: The assignment for today's lesson "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-14 12:15 -0500
                Re: The assignment for today's lesson Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-14 16:01 -0500
            Re: The assignment for today's lesson Richard Damon <Richard@Damon-Family.org> - 2016-11-13 22:25 -0500
              Re: The assignment for today's lesson Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-14 12:05 +0000
            Re: The assignment for today's lesson "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-14 12:14 -0500
              Re: The assignment for today's lesson Keith Thompson <kst-u@mib.org> - 2016-11-14 09:50 -0800
          Re: The assignment for today's lesson Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-14 00:42 +0000
            Re: The assignment for today's lesson Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-13 21:48 -0500

csiph-web