fputs version

一、源代码:  

1 #include "apue.h"

  2 int main()
  1 #include "apue.h"
  2 int main()
  3 {
  4         char buf[MAXLINE];
  5         while (fgets(buf,MAXLINE,stdin) != EOF)
  6                 if (fputs(buf,stdout) == EOF)
  7                         err_sys("fputs error");
  8
  9         if (ferror(stdin))
 10                 err_sys("fgets error");
 11
 12         exit(0);

 13 }

二、编译:

R*_*G:gcc -Wall -ggdb3 -o fputs_version 5_5.c
In file included from apue.h:132,
                 from 5_5.c:1:
error.c: In function `err_doit':
error.c:121: warning: implicit declaration of function `vsnprintf'
error.c:123: warning: implicit declaration of function `snprintf'
5_5.c: In function `main':
5_5.c:5: warning: comparison between pointer and integer


三、运行:
R*_*G:./fputs_version
hello
hello
^CR*_*G:

你可能感兴趣的:(apue)