Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6533923
  • 博文数量: 915
  • 博客积分: 17977
  • 博客等级: 上将
  • 技术积分: 8846
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-26 09:59
个人简介

一个好老好老的老程序员了。

文章分类

全部博文(915)

文章存档

2022年(9)

2021年(13)

2020年(10)

2019年(40)

2018年(88)

2017年(130)

2015年(5)

2014年(12)

2013年(41)

2012年(36)

2011年(272)

2010年(1)

2009年(53)

2008年(65)

2007年(47)

2006年(81)

2005年(12)

分类: C/C++

2012-10-11 16:59:38


 

点击(此处)折叠或打开

  1. # include <stdlib.h>
  2. # include <stdio.h>


  3. int main(int argc, char *argv[])
  4. {
  5.     FILE **outfile;
  6.     int c, i;
  7.     int value = 0;
  8.     outfile = (FILE **) malloc (argc * sizeof (FILE *));
  9.     outfile [0] = stdout;
  10.     for (i = 1; i < argc; ++i)
  11.     {
  12.         if ((outfile [i] = fopen (argv[i],"wb")) == NULL) {
  13.             fprintf (stderr, "%s: ", argv [0]);
  14.             perror (argv[i]);
  15.             value = 1;
  16.         }
  17.     }
  18.     while ((c = getchar ()) != EOF)
  19.     {
  20.         for (i = 0; i < argc; ++i)
  21.         {
  22.             if (outfile [i] != NULL) {
  23.                 if (fputc (c, outfile [i]) == EOF) value = 1;
  24.             }
  25.         }
  26.     }
  27.     for (i = 0; i < argc; ++i)
  28.     {
  29.         fclose (outfile [i]);
  30.     }
  31.     return value;
  32. }


 

阅读(5193) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~