๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Conversion int --> char

#15660
From: Alain CROS
Date: Wed, 14 Sep 2005 16:29
25 lines
1297 bytes
Bonjour.

La fonction getchar retourne un int que je peux stocker dans un char sans que le compilateur ne se manifeste.
Est ce toujours vrai ou bien mon syst๏ฟฝme est bien gentil avec moi ?
Merci.

Alain CROS

#include <stdio.h>

int main(void)
 {
 char string[10];
 char *pstr = string;
 unsigned int i, j = 1;
 while((i = getchar()) != '\n' && j < 10)
  {
  *pstr = i;
  pstr++;
  j++;
  }
 *pstr = '\0';
 printf("\n%s\nj = %d\n", string, j);
 return 0;
}
Technical Details
Message-ID: <43285040$0$14548$636a55ce@news.free.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!proxad.net!infeed-4.proxad.net!newsr4-1.free.fr!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,2c3d52d9f1b4dc77,start
X-Google-Attributes: gidf9822,public
X-Google-Language: FRENCH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!proxad.net!infeed-4.proxad.net!newsr4-1.free.fr!not-for-mail
From: "Alain CROS" <Personne@ICI>
Newsgroups: fr.comp.lang.c
Subject: Conversion int --> char
Date: Wed, 14 Sep 2005 18:29:53 +0200
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Lines: 27
Message-ID: <43285040$0$14548$636a55ce@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 14 Sep 2005 18:30:57 MEST
NNTP-Posting-Host: 62.147.11.158
X-Trace: 1126715457 newsr4-1.free.fr 14548 62.147.11.158:1038
X-Complaints-To: abuse@proxad.net