delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/02/03/11:39:22

Date: Wed, 3 Feb 1999 11:24:05 -0500
Message-Id: <199902031624.LAA25599@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp-workers AT delorie DOT com
Subject: [matecka AT hron DOT fei DOT tuke DOT sk: 'putc' problem]
Reply-To: djgpp-workers AT delorie DOT com

------- Start of forwarded message -------
Return-Path: <matecka AT hron DOT fei DOT tuke DOT sk>
From: Matecka Lubomir <matecka AT hron DOT fei DOT tuke DOT sk>
Subject: 'putc' problem
To: dj AT delorie DOT com
Date: Wed, 3 Feb 1999 12:40:31 +0100 (MET)
Content-Type: text

hello,

there is some problem with 'putc' in djgpp v2.01. it should only return
EOF when error occured, but it also returns EOF (= -1) when first
character
sent to created file is 0xff
consider following code:

#include <stdio.h>

void main (void)
{
    FILE *f;
    char c=0xff;
    int i;

    f=fopen ("test.bug", "wb");
    if (!f) return;

    for (i=0; i<3; i++)
	printf ("%d\n", putc (c, f));

    fclose (f);
}

it should print: 255 255 255 on screen (at least this is what this code
compiled with other compilers do) but compiled with djgpp it 
prints: -1 255 255,
so comparison with EOF atfer first call of 'putc' makes 'true'.
note, that this problem doesn't appear when 'c' is defined as 'unsigned
char'

lubo matecka (misty)
matecka AT hron DOT fei DOT tuke DOT sk
------- End of forwarded message -------

- Raw text -


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