home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!mcsun!sun4nl!tnofel!felfs!rioj7
- From: rioj7@fel.tno.nl (M.L.M.Veraart)
- Subject: Re: How do you read binary data piped into stdin?
- Organization: TNO Physics and Electronics Laboratory
- Date: Tue, 26 Jan 93 08:07:18 GMT
- Message-ID: <1993Jan26.080718.19485@fel.tno.nl>
- References: <N0gRXB1w165w@eastwind.mcds.com>
- Keywords: stdin, redirection, binary data
- Lines: 25
-
- chorn@eastwind.mcds.com (Christopher Horn) writes:
-
-
- >I'm relatively new to C, so still have a lot to learn, so I apologize
- >if this is a silly question. I need to read raw binary data from
- >stdin (it is being piped in) but it appears stdin operates in text
- >mode. The first ascii 26 that comes along triggers end of file, and
- >I can't read the rest of the data. Could someone please explain, or
- >better yet show me a short peice of code, that could do this? The
- >answer is probably obvious, but it eludes me at the moment. Thanks
- >a lot!
-
- Christopher, because you don't show a small piece of code you use
- I think that you use the function scanf(). If you use the function
- fread(stdin, ) I think this will read binary data, because scanf()
- has an ascii interface built in.
-
- Try it and let us know.
-
- Mario
- --
- Mario Veraart TNO Physics and Electronics Laboratory
- email: rioj7@fel.tno.nl The Hague The Netherlands
- "If all else fails, show pretty pictures and animated videos,
- and don't talk about performance", David Bailey
-