Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #109620
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Printing like palindrome |
| Date | 2017-05-09 12:33 -0700 |
| Organization | None to speak of |
| Message-ID | <lntw4t965w.fsf@kst-u.example.com> (permalink) |
| References | <5911a0f4$0$294$14726298@news.sunsite.dk> <p093hc1ll75lunca1bsh8k9ahd7efpvduq@4ax.com> <tl44hchl4uroj983a5pbvd0sseovn611dg@4ax.com> |
Robert Wessel <robertwessel2@yahoo.com> writes:
[...]
> Is that sufficient? I know C doesn't require A..Z to be contiguous,
> but does it require the alphabet to be in ascending order in the
> character set? I'm not aware that it does (the requirements for the
> digits to be ascending and contiguous is quite explicit and specific).
It doesn't. Both EBCDIC and the various ASCII-based character sets do
have the letters in order, but there's no such requirement.
> I know of character sets where the letters are not in the conventional
> order (that various Baudot codes, for example), but I don't know of
> any implementations of C that actually use such.
Nor do I.
But if you want to write code that doesn't make any such assumptions,
you can define an array:
const char upper[26] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
and iterate over it.
Of course you *can* just assume that the letters are contiguous and
ordered, but if you do I suggest clearly documenting the assumption,
and perhaps even checking it ('Z' - 'A' == 25 isn't a perfect test,
but it's something).
You might also think about non-Latin letters.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Printing like palindrome arnuld <sunrise@invalid.address> - 2017-05-09 10:59 +0000
Re: Printing like palindrome Barry Schwarz <schwarzb@dqel.com> - 2017-05-09 04:26 -0700
Re: Printing like palindrome Robert Wessel <robertwessel2@yahoo.com> - 2017-05-09 14:10 -0500
Re: Printing like palindrome Keith Thompson <kst-u@mib.org> - 2017-05-09 12:33 -0700
Re: Printing like palindrome Richard Heathfield <rjh@cpax.org.uk> - 2017-05-09 23:05 +0100
Re: Printing like palindrome raltbos@xs4all.nl (Richard Bos) - 2017-05-10 10:25 +0000
Re: Printing like palindrome Richard Heathfield <rjh@cpax.org.uk> - 2017-05-10 11:44 +0100
Re: Printing like palindrome Keith Thompson <kst-u@mib.org> - 2017-05-10 09:48 -0700
Re: Printing like palindrome Gareth Owen <gwowen@gmail.com> - 2017-05-10 18:59 +0100
Re: Printing like palindrome arnuld <sunrise@invalid.address> - 2017-05-12 07:14 +0000
Re: Printing like palindrome arnuld <sunrise@invalid.address> - 2017-05-12 07:44 +0000
Re: Printing like palindrome arnuld <sunrise@invalid.address> - 2017-05-12 07:20 +0000
Re: Printing like palindrome Keith Thompson <kst-u@mib.org> - 2017-05-12 08:49 -0700
Re: Printing like palindrome arnuld <sunrise@invalid.address> - 2017-05-14 02:01 +0000
Re: Printing like palindrome mark.bluemel@gmail.com - 2017-05-09 07:13 -0700
Re: Printing like palindrome scott@slp53.sl.home (Scott Lurndal) - 2017-05-09 14:59 +0000
Re: Printing like palindrome Keith Thompson <kst-u@mib.org> - 2017-05-09 08:27 -0700
Re: Printing like palindrome Barry Schwarz <schwarzb@dqel.com> - 2017-05-09 10:40 -0700
Re: Printing like palindrome scott@slp53.sl.home (Scott Lurndal) - 2017-05-09 14:38 +0000
Re: Printing like palindrome Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-09 22:48 +0100
Re: Printing like palindrome scott@slp53.sl.home (Scott Lurndal) - 2017-05-10 13:21 +0000
Re: Printing like palindrome Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-10 15:45 +0100
Re: Printing like palindrome Barry Schwarz <schwarzb@dqel.com> - 2017-05-10 10:26 -0700
Re: Printing like palindrome bartc <bc@freeuk.com> - 2017-05-09 21:28 +0100
Re: Printing like palindrome raltbos@xs4all.nl (Richard Bos) - 2017-05-10 10:27 +0000
Re: Printing like palindrome Chad <cdalten@gmail.com> - 2017-05-10 10:39 -0700
Re: Printing like palindrome bartc <bc@freeuk.com> - 2017-05-10 12:54 +0100
Printing like palindrome asetofsymbols@gmail.com - 2017-05-12 02:32 -0700
csiph-web