Mail Archives: djgpp/2001/02/28/08:27:35

From: "Rafael García" <rafael AT geninfor DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: atoi() with 8 bit chars
Date: Wed, 28 Feb 2001 14:09:30 +0100
Organization: BT Tel. Netnews service (readers)
Lines: 25
Message-ID: <3a9cf8f1$>
Mime-Version: 1.0
X-Trace: 983365786 23179 (28 Feb 2001 13:09:46 GMT)
X-Complaints-To: abuse AT bt DOT es
NNTP-Posting-Date: 28 Feb 2001 13:09:46 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello all. I have found a bug in one of my functions due to an extrange
behaviour of atoi() with bad data introduced by a user in a date. If you
give 8-bit chars to atoi, it does not return cero. Does anybody know why?

#include <stdio.h>
#include <stdlib.h>

int main() {
   int n;
   char s1[]="?";
   char s2[]="?0";

   for (n=0;n<=255;n++) {
   return 0;

- Raw text -

  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019