File: mycopy3.c

package info (click to toggle)
genparse 0.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 3,272 kB
  • ctags: 2,718
  • sloc: ansic: 8,794; cpp: 6,060; sh: 5,175; java: 578; yacc: 482; makefile: 344; lex: 315
file content (42 lines) | stat: -rw-r--r-- 602 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* mycopy3.c */

#include <stdio.h>
#include <stdlib.h>
#include "mycopy3_clp.h"

#define VERSION "3.0"

int main (int argc, char *argv[])
{
  int c, i;
  FILE *fp, *ofp;
  struct arg_t a;

  Cmdline (&a, argc, argv);

  if (a.v)
    {
      printf ("%s version %s\n", argv[0], VERSION);
      exit (0);
    }

  if (a.o)
    ofp = fopen (a.o, "w");
  else
    ofp = stdout;
  
  if (!a.optind)
    fp = stdin;
  else
    fp = fopen (argv[a.optind],"r");

  for (i = 0; i < a.i; i++)
    {
      while ((c = fgetc (fp)) != EOF)
	fputc (c, ofp);
      rewind (fp);
    }
  
  fclose (fp);
  return 0;
}