Re: Portability question
From: Emmanuel Delahaye (emdelYOURBRA_at_noos.fr)
Date: 03/28/04
- Next message: Ben Pfaff: "Re: Newb- Global Array"
- Previous message: John Douglas: "Re: event generation"
- In reply to: john: "Portability question"
- Next in thread: Malcolm: "Re: Portability question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Mar 2004 19:35:44 GMT
In 'comp.lang.c', john <john@nospam.uk> wrote:
> New to C and working through chapter 1 of K&R2. In the program in 1.6,
> they use
>
> if (c >= '0' && c <= '9')
> ++ndigit[c-'0'];
>
> to count the occurrences of each digit in the input and put the result in
> an int array. According to them, 'This only works if '0', '1', ..., '9'
> have consecutive increasing values. Fortunately, this is true for all
> character sets.'
It true for the digits. A conforming C-implementation must have a charset
where digits values are consecutive and increasing.
The code is portable, as far as the implementation is conforming to the C
standard.
-- -ed- emdelYOURBRA@noos.fr [remove YOURBRA before answering me] The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=cpp FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
- Next message: Ben Pfaff: "Re: Newb- Global Array"
- Previous message: John Douglas: "Re: event generation"
- In reply to: john: "Portability question"
- Next in thread: Malcolm: "Re: Portability question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|