Mail Archives: djgpp/2011/03/16/06:27:43
> From: RayeR <glaux AT centrum DOT cz>
> Newsgroups: comp.os.msdos.djgpp
> Date: Wed, 16 Mar 2011 02:07:00 -0700 (PDT)
>
> Under msdos I got null pointer as expected according to ansi c spec.
> If I then tried to write to NULL by fwrite() program crashed.
> Under freedos it opened something (NUL device?) and fopen returned a
> valid pointer. fwrite() didn't crashed, fclose() didn't return error.
> But of course file was not created. I think this is a bad idea because
You can see the system calls in djlsr203.zip (assuming you use DJGPP
v2.03, that is). What happens is that fwrite copies data to a buffer
until it is full, then calls _flsbuf (see flsbuf.c in djlsr203.zip),
which in turn calls _write (see _write.c) which invokes Int 21h with
the AH register set to 40h, the DOS Write To File Or Device function.
As for fopen, the exact sequence of system calls depends on the flags
you passed to it. I think it eventually calls Int 21h AH=3Ch (Create
File), but I cannot tell for sure without seeing your code.
- Raw text -