Article View: fr.comp.lang.c
Article #15055bug dans un petit programme
From: Thierry B
Date: Sun, 16 Oct 2005 10:01
Date: Sun, 16 Oct 2005 10:01
42 lines
2061 bytes
2061 bytes
Bonjour,
Je voulais vous poser une petite question.
Voici un tout petit programme C:
#define _POSIX_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
int arg;
char *buf;
printf("Nombre d'argument: %d\n",argc);
arg = atoi(argv[1]);
if (arg < 5) {
sprintf(buf, "%d", arg);
printf("Le nombre est %s.\n",buf);
}
return 0;
}
Quand je le lance, il me met ca:
thierry@debian:~/Master/Posix/Supplement_Semaine2$ ./bin/exo3 2
Nombre d'argument: 2
Le nombre est 2.
3599:
3599: calling fini: /lib/tls/libc.so.6 [0]
3599:
Il m'affiche bien le résultat, mais il met aussi des lignes bizarres,
mais quand je remplace sprintf(buf, "%d", arg) par sprintf(buf, " %d",
arg) cad en ajoutant juste un espace entre le " et %d, ca marche nikel.
Quelqu'un a une idée?
Merci
A+
Technical Details
Message-ID:
<1129454997.732041.79560@g43g2000cwa.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!g43g2000cwa.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: f9822,825aa0bc6fede96b,start X-Google-Attributes: gidf9822,public X-Google-Language: FRENCH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!g43g2000cwa.googlegroups.com!not-for-mail From: "Thierry B" <thierry.bouhnik@gmail.com> Newsgroups: fr.comp.lang.c Subject: bug dans un petit programme Date: 16 Oct 2005 03:01:59 -0700 Organization: http://groups.google.com Lines: 43 Message-ID: <1129454997.732041.79560@g43g2000cwa.googlegroups.com> NNTP-Posting-Host: 82.224.47.63 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1129456925 26445 127.0.0.1 (16 Oct 2005 10:02:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 16 Oct 2005 10:02:05 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.7.12) Gecko/20050920 Firefox/1.0.7,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g43g2000cwa.googlegroups.com; posting-host=82.224.47.63; posting-account=8zpqDA0AAACpm8oU5_TKS1gqRyX3CEVa