home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20209 < prev    next >
Encoding:
Text File  |  1993-01-26  |  1.4 KB  |  37 lines

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