🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.lang.c
Article #15467

Re: conjugaison et autres exos sur les chaines [Was : Un système de conj...]

#15467
From: Emmanuel Delahaye
Date: Wed, 21 Sep 2005 20:30
114 lines
4628 bytes
(supersedes <mn.ad417d590cf08264.15512@YOURBRAnoos.fr>)

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'

main.c: In function `usage':

main.c:16: warning: function might be possible candidate for attribute 
`noreturn'
main.c: In function `main_':
main.c:23: error: implicit declaration of function `sqrtl'
main.c:23: warning: nested extern declaration of `sqrtl'
<internal>:0: warning: redundant redeclaration of 'sqrtl'
main.c:27: error: implicit declaration of function `isspace'

main.c:27: warning: nested extern declaration of `isspace'

Petite mise au point...

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <inttypes.h>
#include <math.h>
#include <limits.h>
#include <ctype.h>

#if 1
#if !defined (__STDC_VERSION__)\
 || (defined (__STDC_VERSION__) && __STDC_VERSION__ < 199901)
#error must be a C99 compiler
#endif
#endif

static void usage (void)
{
   puts ("Syntaxe: icarre valeur (representant un entier)\n"
         "Mais Auchan vend des trucs qui le font\n"
         "pour moins d'un euro, et sans ordinateur.");
}

int main (int argc, char *argv[])
{
   int ret = EXIT_SUCCESS;

   if (argc == 2)
   {
      const uintmax_t borne = sqrtl ((long double) UINTMAX_MAX);
      char const *pvaleur = argv[1];

      while (pvaleur[0] == '-' || isspace (pvaleur[0]))
      {
         pvaleur++;
      }

      uintmax_t entier = strtoumax (pvaleur, NULL, 0);

      if (errno || (entier > borne))
      {
         puts ("Oh my God, c'est henaurme !");
      }
      else
      {
         printf ("%" PRIuMAX "\n", entier * entier);
      }
   }
   else
   {
      usage ();
      ret = EXIT_FAILURE;
   }
   return ret;
}


-- 
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

 I once asked an expert COBOL programmer, how to
declare local variables in COBOL, the reply was:
 "what is a local variable?"
Technical Details
Message-ID: <mn.ad467d5958d83976.15512@YOURBRAnoos.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!proxad.net!infeed-4.proxad.net!news18-e.free.fr!not-for-mail
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>

Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,b21b26167a936e28
X-Google-Attributes: gidf9822,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!proxad.net!infeed-4.proxad.net!news18-e.free.fr!not-for-mail
Subject: Re: conjugaison et autres exos sur les chaines [Was : Un système de conj...]
From: "Emmanuel Delahaye" <emdel@YOURBRAnoos.fr>
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>
Newsgroups: fr.comp.lang.c
Message-ID: <mn.ad467d5958d83976.15512@YOURBRAnoos.fr>
Supersedes: <mn.ad417d590cf08264.15512@YOURBRAnoos.fr>
X-Newsreader: MesNews/1.04.00.00-fr
Date: Wed, 21 Sep 2005 22:30:14 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 116
Organization: Guest of ProXad - France
NNTP-Posting-Date: 21 Sep 2005 22:30:17 MEST
NNTP-Posting-Host: 81.65.109.78
X-Trace: 1127334617 news18-e.free.fr 7357 81.65.109.78:14361
X-Complaints-To: abuse@proxad.net