www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/04/09/14:37:11

Sender: nate AT cartsys DOT com
Message-ID: <370E48DF.1BAAA425@cartsys.com>
Date: Fri, 09 Apr 1999 11:37:19 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.5 i586)
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: fflush question
References: <199904090117 DOT VAA28719 AT spock2 DOT ECE DOT McGill DOT CA> <199904090126 DOT VAA27042 AT envy DOT delorie DOT com>
Reply-To: djgpp-workers AT delorie DOT com

DJ Delorie wrote:

> > DJGPP doesn't maintain a consistent view of the file.
> 
> Like I said, it's not DJGPP it's DOS.  Turbo-C should show the same
> behavior (can someone verify this?) with your example.

Actually, this test program (which could someone please spot-check for
me? :) prints 1 on MS-DOS 5 and Windows 98 DOS box, whether compiled
with Turbo C (TC++ 1.01) or DJGPP.  Interesting.

#include <stdio.h>
#include <io.h>
#include <fcntl.h>

int main(void)
{
        char d, c = '1';
        int a, b;
        a = open ("foo", O_CREAT¦O_WRONLY, 0644);
        write(a, &c, 1);
        b = open ("foo", O_RDONLY);
        printf("Read %d bytes\n", read (b, &d, 1));
        printf("d=%d ('%c')\n", d, d);
        return 0;
}

Using _read and _write changes nothing.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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