home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!spool.mu.edu!sdd.hp.com!uakari.primate.wisc.edu!eng.ufl.edu!whale!zzang
- From: zzang@whale.uucp (Zhuo Zang[~{j0WA~}])
- Subject: Help! what's wrong with this program?
- Message-ID: <1992Sep6.041410.16388@eng.ufl.edu>
- Sender: news@eng.ufl.edu (Usenet Diskhog System)
- Organization: University of Florida
- Distribution: usa
- Date: Sun, 6 Sep 92 04:14:10 GMT
- Lines: 33
-
- Hello,
- I try to push char c onto buf, and then
- print out the buf.
- But the following codes don't work.
- After compilation, I use
- > foo <foo.c
- nothing printed out.
-
- Could someone tell me why ?
-
- Thanks in advance !
- --------- foo.c ----------
- #include <stdio.h>
- char *sp, buf[BUFSIZ], c;
- main()
- {
- sp = buf;
- while ((c=getchar())!=EOF) pushc(c,sp);
- *sp = '\0';
-
- puts(buf);
- return;
- }
-
- pushc(char c, char *bp)
- {
- *bp++ = c;
- return;
- }
- --
- Zhuo Zang[~{j0WA~}]
- Department of Statistics
- University of Florida Email: zzang@stat.ufl.edu
-