Article View: fr.comp.lang.c
Article #15244Re: rot13 [Was : Re: conjugaison et autres ...]
From: Charlie Gordon
Date: Mon, 03 Oct 2005 02:13
Date: Mon, 03 Oct 2005 02:13
63 lines
3293 bytes
3293 bytes
"Emmanuel Delahaye" <emdel@YOURBRAnoos.fr> wrote in message
news:mn.150f7d5a4aa81b4e.15512@YOURBRAnoos.fr...
[...]
> int main (void)
> {
> char minus[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklm";
> char majus[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM";
> char phrase[200] = "Preface : The computing world has undergone a"
> " revolution since the publication of \"The C Programming
> Language\""
> " in 1978.\n";
Je d�clarerais ces tableaux static pour �viter une initialization couteuse de
tableaux automatiques.
De plus ils sont const:
static char const minus[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklm";
static char const majus[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM";
static char const phrase[200] = "Preface : The computing world has undergone a"
" revolution since the publication of \"The C Programming
Language\""
" in 1978.\n";
>
> /*
> Cersnpr : Gur pbzchgvat jbeyq unf haqretbar n eribyhgvba fvapr gur
> choyvpngvba b
> s "Gur P Cebtenzzvat Ynathntr" va 1978.
> */
> char *pc = phrase;
Mettons plutot const char *pc = phrase; puisque phrase n'est pas modifi�.
> int c;
>
> while ((c = *pc) != 0)
> {
> if (islower (c))
> {
> char *p = strchr (minus, c);
> putchar (p[13]);
> }
> else if (isupper (c))
> {
> char *p = strchr (majus, c);
> putchar (p[13]);
> }
> else
> {
> putchar (c);
> }
> pc++;
> }
>
> return 0;
> }
Cela reste plus laborieux que d'utiliser un tableau indic� par les char (cast en
unsigned char pour �viter le probl�me des char sign�s ;-).
comme le propose Richard Delorme.
--
Chqrlie.
Technical Details
Message-ID:
<dhq2kp$d7m$1@reader1.imaginet.fr>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!213.193.255.2.MISMATCH!feeder1.cambrium.nl!feed.tweaknews.nl!newsgate.cistron.nl!news.nl.colt.net!colt.net!fr.colt.net!writer!not-for-mailReferences:
<1126342327.583568.21420@g43g2000cwa.googlegroups.com> <4329e5d4$0$7846$8fcfb975@news.wanadoo.fr> <dge4b6$fqa$1@reader1.imaginet.fr> <432ab809$0$1734$8fcfb975@news.wanadoo.fr> <mn.84b07d59016a857b.31483@laposte.net> <433f16ac$0$27406$8fcfb975@news.wanadoo.fr> <mn.10907d5a55119e84.15512@YOURBRAnoos.fr> <433f9cb1$0$7821$8fcfb975@news.wanadoo.fr> <mn.128c7d5aa5238de0.15512@YOURBRAnoos.fr> <43402c57$0$1702$8fcfb975@news.wanadoo.fr> <mn.150f7d5a4aa81b4e.15512@YOURBRAnoos.fr>Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,b21b26167a936e28 X-Google-Attributes: gidf9822,public X-Google-Language: FRENCH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!213.193.255.2.MISMATCH!feeder1.cambrium.nl!feed.tweaknews.nl!newsgate.cistron.nl!news.nl.colt.net!colt.net!fr.colt.net!writer!not-for-mail From: "Charlie Gordon" <news@chqrlie.org> Newsgroups: fr.comp.lang.c Subject: Re: rot13 [Was : Re: conjugaison et autres ...] Date: Mon, 3 Oct 2005 04:13:57 +0200 Organization: ImagiNET / Colt Internet Lines: 65 Message-ID: <dhq2kp$d7m$1@reader1.imaginet.fr> References: <1126342327.583568.21420@g43g2000cwa.googlegroups.com> <4329e5d4$0$7846$8fcfb975@news.wanadoo.fr> <dge4b6$fqa$1@reader1.imaginet.fr> <432ab809$0$1734$8fcfb975@news.wanadoo.fr> <mn.84b07d59016a857b.31483@laposte.net> <433f16ac$0$27406$8fcfb975@news.wanadoo.fr> <mn.10907d5a55119e84.15512@YOURBRAnoos.fr> <433f9cb1$0$7821$8fcfb975@news.wanadoo.fr> <mn.128c7d5aa5238de0.15512@YOURBRAnoos.fr> <43402c57$0$1702$8fcfb975@news.wanadoo.fr> <mn.150f7d5a4aa81b4e.15512@YOURBRAnoos.fr> NNTP-Posting-Host: gw.netgem.com X-Trace: reader1.imaginet.fr 1128304089 13558 195.68.2.34 (3 Oct 2005 01:48:09 GMT) X-Complaints-To: abuse@imaginet.fr NNTP-Posting-Date: 3 Oct 2005 01:48:09 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1506 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506