Article View: fr.comp.lang.c
Article #15472Re: conjugaison et autres exos sur les chaines [Was : Un système de conj...]
From: Antoine Leca
Date: Thu, 22 Sep 2005 10:59
Date: Thu, 22 Sep 2005 10:59
92 lines
4465 bytes
4465 bytes
En <news:mn.ad467d5958d83976.15512@YOURBRAnoos.fr>,
Emmanuel Delahaye va escriure:
>
> Pierre Maurette wrote on 21/09/05 :
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <errno.h>
>> #include <inttypes.h>
>>
>> void usage(void)
>> {
>> puts("Syntaxe: icarre valeur (repr�sentant un entier)\nMais Auchan
>> vend des trucs qui le font\npour moins d'un euro, et sans
>> ordinateur."); exit(EXIT_SUCCESS);
>> }
>>
>> int main(int argc, char * argv[])
>> {
>> uintmax_t entier;
>> char * pvaleur = NULL;
>> const uintmax_t borne = sqrtl((long double)UINTMAX_MAX);
>>
>> if(argc != 2) usage();
>> pvaleur = argv[1];
>> while(pvaleur[0] == '-' || isspace(pvaleur[0])) pvaleur++;
>> entier = strtoumax(pvaleur, NULL, 0);
>> if(errno || (entier > borne))
>> puts("Oh my God, c'est h�naurme !");
>> else
>> printf("%" PRIuMAX "\n", entier * entier);
>> return EXIT_SUCCESS;
>> }
>
> Un peu brut de d�coffrage...
>
> main.c:13: warning: no previous prototype for 'usage'
Quelle utilit� ?
(En plus, je ne comprends pas comment tu obtiens 13).
> main.c: In function `usage':
>
> main.c:16: warning: function might be possible candidate for attribute
> `noreturn'
Verbeux.
> #include <inttypes.h>
>
> #if 1
> #if !defined (__STDC_VERSION__)\
> || (defined (__STDC_VERSION__) && __STDC_VERSION__ < 199901)
> #error must be a C99 compiler
> #endif
> #endif
Avant l'#include <inttypes.h>, ce serait mieux.
> int ret = EXIT_SUCCESS;
Pr�somptueux ;-)
> if (argc == 2)
> {
[ GROOOOOOS couic ]
> }
> else
> {
> usage ();
Mouais. C'est du style, c'est s�r, mais tu fais vraiment cela en production,
de mettre le cas court tout en bas ?
Je sais bien que tu n'aime pas la forme
if( d�tection des mauvais coups ) {
protestations �ventuelles;
return CODE_ERREUR;
}
mais c'est quand m�me plus clair dans des cas comme celui-l�, non ? (�
condition bien s�r de les garder au d�but de la fonction et ne pas les
parsemer tout au long, cela a m�me des vertus documentaires, alors que ton
code m'a enduit d'erreur, je pensais que tu r�p�tais le code de Pierre quant
� la valeur retourn�e...)
Antoine
Technical Details
Message-ID:
<dgu2qs$oa1$1@shakotay.alphanet.ch>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsfeed.gamma.ru!Gamma.RU!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!newsfeed.stueberl.de!newsfeed.vmunix.org!news.imp.ch!news.imp.ch!80.83.46.147.MISMATCH!news.alphanet.ch!alphanet.ch!not-for-mailReferences:
<1126342327.583568.21420@g43g2000cwa.googlegroups.com> <4329e5d4$0$7846$8fcfb975@news.wanadoo.fr> <dge4b6$fqa$1@reader1.imaginet.fr> <mn.837a7d59123d924a.15512@YOURBRAnoos.fr> <432adddf$0$17220$8fcfb975@news.wanadoo.fr> <mn.84407d597cfa6e6e.15512@YOURBRAnoos.fr> <432b2a92$0$7861$8fcfb975@news.wanadoo.fr> <432c19e0$0$1710$8fcfb975@news.wanadoo.fr> <432cad90$0$27422$8fcfb975@news.wanadoo.fr> <432d1b7c$0$1743$8fcfb975@news.wanadoo.fr> <432d3117$0$1742$8fcfb975@news.wanadoo.fr> <mn.93877d590449a7bc.15512@YOURBRAnoos.fr> <432d7667$0$17248$8fcfb975@news.wanadoo.fr> <mn.94047d599f0cc076.15512@YOURBRAnoos.fr> <432da70c$0$1735$8fcfb975@news.wanadoo.fr> <mn.94c47d590202e83a.15512@YOURBRAnoos.fr> <43315679$0$27421$8fcfb975@news.wanadoo.fr> <mn.ad0b7d59687aaf3b.31483@laposte.net> <mn.ad467d5958d83976.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!news1.google.com!newsfeed.gamma.ru!Gamma.RU!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!newsfeed.stueberl.de!newsfeed.vmunix.org!news.imp.ch!news.imp.ch!80.83.46.147.MISMATCH!news.alphanet.ch!alphanet.ch!not-for-mail From: "Antoine Leca" <root@localhost.invalid> Newsgroups: fr.comp.lang.c Subject: Re: conjugaison et autres exos sur les chaines [Was : Un système de conj...] Date: Thu, 22 Sep 2005 12:59:39 +0200 Organization: Posted through ALPHANET (http://www.alphanet.ch/) Lines: 93 Sender: antoinel@143.red-217-127-250.staticip.rima-tde.net Message-ID: <dgu2qs$oa1$1@shakotay.alphanet.ch> References: <1126342327.583568.21420@g43g2000cwa.googlegroups.com> <4329e5d4$0$7846$8fcfb975@news.wanadoo.fr> <dge4b6$fqa$1@reader1.imaginet.fr> <mn.837a7d59123d924a.15512@YOURBRAnoos.fr> <432adddf$0$17220$8fcfb975@news.wanadoo.fr> <mn.84407d597cfa6e6e.15512@YOURBRAnoos.fr> <432b2a92$0$7861$8fcfb975@news.wanadoo.fr> <432c19e0$0$1710$8fcfb975@news.wanadoo.fr> <432cad90$0$27422$8fcfb975@news.wanadoo.fr> <432d1b7c$0$1743$8fcfb975@news.wanadoo.fr> <432d3117$0$1742$8fcfb975@news.wanadoo.fr> <mn.93877d590449a7bc.15512@YOURBRAnoos.fr> <432d7667$0$17248$8fcfb975@news.wanadoo.fr> <mn.94047d599f0cc076.15512@YOURBRAnoos.fr> <432da70c$0$1735$8fcfb975@news.wanadoo.fr> <mn.94c47d590202e83a.15512@YOURBRAnoos.fr> <43315679$0$27421$8fcfb975@news.wanadoo.fr> <mn.ad0b7d59687aaf3b.31483@laposte.net> <mn.ad467d5958d83976.15512@YOURBRAnoos.fr> NNTP-Posting-Host: 143.red-217-127-250.staticip.rima-tde.net Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit X-Trace: shakotay.alphanet.ch 1127386780 24897 217.127.250.143 (22 Sep 2005 10:59:40 GMT) X-Complaints-To: usenet@alphanet.ch NNTP-Posting-Date: Thu, 22 Sep 2005 10:59:40 +0000 (UTC) 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