home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13270 < prev    next >
Encoding:
Text File  |  1992-09-08  |  948 b   |  45 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!spool.mu.edu!sdd.hp.com!uakari.primate.wisc.edu!eng.ufl.edu!whale!zzang
  3. From: zzang@whale.uucp (Zhuo Zang[~{j0WA~}])
  4. Subject: Help! what's wrong with this program?
  5. Message-ID: <1992Sep6.041410.16388@eng.ufl.edu>
  6. Sender: news@eng.ufl.edu (Usenet Diskhog System)
  7. Organization: University of Florida
  8. Distribution: usa
  9. Date: Sun, 6 Sep 92 04:14:10 GMT
  10. Lines: 33
  11.  
  12. Hello,
  13. I try to push char c onto buf, and then
  14. print out the buf.
  15. But the following codes don't work.
  16. After compilation, I use
  17. > foo <foo.c
  18. nothing printed out.
  19.  
  20. Could someone tell me why ?
  21.  
  22. Thanks in advance !
  23. --------- foo.c ----------
  24. #include <stdio.h>
  25. char *sp, buf[BUFSIZ], c;
  26. main()
  27. {
  28.   sp = buf;
  29.   while ((c=getchar())!=EOF) pushc(c,sp);
  30.   *sp = '\0';
  31.  
  32.   puts(buf);
  33.   return;
  34. }
  35.  
  36. pushc(char c, char *bp)
  37. {
  38.   *bp++ = c;
  39.   return;
  40. }
  41. -- 
  42. Zhuo Zang[~{j0WA~}]
  43. Department of Statistics
  44. University of Florida            Email: zzang@stat.ufl.edu
  45.