[comp.windows.ms.programmer] Stream I/O in Windows

kam@iti.org (Keith A. McNabb) (06/12/91)

Has anyone found a way to use or emulate the C run-time stream I/O
functions, particularly fscanf().  Microsoft documentation suggests
using only the low-level read() and write() functions.  That's a lot of
bother if you're adapting existing code, as fscanf advances the file
pointer and recognizes EOF, something sscanf() doesn't do.

Obviously, one could make up a "fake" fscanf based on the size of 
the file and all.  I'm just trying to make sure I'm not re-inventing
the wheel here.

Any suggestions appreciated.

Keith McNabb
kam@iti.org

cadsi@ccad.uiowa.edu (CADSI) (06/12/91)

From article <1991Jun11.190819.13143@iti.org>, by kam@iti.org (Keith A. McNabb):
> 
> Has anyone found a way to use or emulate the C run-time stream I/O
> functions, particularly fscanf().  Microsoft documentation suggests
> using only the low-level read() and write() functions.  That's a lot of
> bother if you're adapting existing code, as fscanf advances the file
> pointer and recognizes EOF, something sscanf() doesn't do.
> 
> Obviously, one could make up a "fake" fscanf based on the size of 
> the file and all.  I'm just trying to make sure I'm not re-inventing
> the wheel here.
> 
> Any suggestions appreciated.

If you really wanna use fscanf and whatnot, just open() the file
and call fdopen() on that file descriptor.  This works, I've done it.
fwrite, fprintf and all the others work after that too.

Next, just to show you what Windows forgot, try a write to file descriptor 0.

Works.  heh, heh.

|----------------------------------------------------------------------------|
|Tom Hite					|  The views expressed by me |
|Manager, Product development			|  are mine, not necessarily |
|CADSI (Computer Aided Design Software Inc.	|  the views of CADSI.       |
|----------------------------------------------------------------------------|