home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 12880 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  1.7 KB

  1. Xref: sparky comp.lang.c:12880 comp.unix.programmer:4469
  2. Newsgroups: comp.lang.c,comp.unix.programmer
  3. Path: sparky!uunet!email!hp
  4. From: hp@vmars.tuwien.ac.at (Peter Holzer)
  5. Subject: Re: I/O With Unix/C
  6. Message-ID: <1992Aug27.190227.12940@email.tuwien.ac.at>
  7. Sender: news@email.tuwien.ac.at
  8. Nntp-Posting-Host: quasi.vmars.tuwien.ac.at
  9. Organization: Technical University Vienna, Dept. for Realtime Systems, AUSTRIA
  10. References: <ZcB7PB1w164w@underg.UUCP>
  11. Date: Thu, 27 Aug 1992 19:02:27 GMT
  12. Lines: 38
  13.  
  14. max@underg.UUCP (Max Cray) writes:
  15.  
  16. >I am trying to do the most basic file I/O on a couple of unix machines (HP835,
  17. >and Sequent S27), and I can not get it to work. For example:
  18.  
  19. >#include <stdio.h>
  20. >main()
  21. >{
  22. >    int c;
  23.  
  24. >    while (c = getchar() != NULL)
  25. >        putchar(c);
  26. >}
  27.  
  28. >On a DOS machine you just compile it, and it works. 
  29.  
  30. I very much doubt that. Your program contains 2 serious bugs. Firstly,
  31. it will not stop at EOF but after the first NUL character it receives
  32. (i.e. probably never). And it will print a character '\1' for every
  33. character it receives (And '\1' is non-printing on many systems, so you
  34. probably won't see anything).
  35.  
  36. >When I compile it on
  37. >a unix machine, it compiles and runs, but I can't seem to redirect input
  38. >and output through it.
  39.  
  40. >ls -l | myfilter > outfile.tmp
  41.  
  42. >If I type the following command it runs, but it still expects the I/O to
  43. >come from the keyboard, and go to the screen.
  44.  
  45. How large was outfile.tmp after you killed the program?
  46.  
  47. -- 
  48. |    _  | Peter J. Holzer                       | Think of it   |
  49. | |_|_) | Technical University Vienna           | as evolution  |
  50. | | |   | Dept. for Real-Time Systems           | in action!    |
  51. | __/   | hp@vmars.tuwien.ac.at                 |     Tony Rand |
  52.