summaryrefslogtreecommitdiff
path: root/netsvcs/clients/Naming/Dump_Restore/createfile.cpp
blob: fbd85b787682022b042a76f462a1e30131067ec0 (plain)
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
#include <stdio.h>
// $Id$

#include <string.h>
#include <math.h>

int 
main (int argc, char **argv)
{
  FILE *infile, *outfile;
  char buf[BUFSIZ];

  if ((infile = fopen (argv[1], "r")) == NULL)
    return -1;

  if ((outfile = fopen (argv[2], "w")) == NULL)
    return -1;

  int count = 0;
  while (::fgets (buf, BUFSIZ, infile))
    {
      buf[::strlen(buf) - 1] = '\0';
      fputs (buf, outfile);
      if (count % 2 == 0)
	fputs (" ", outfile);
      else
	fputs ("\n", outfile);
      count++;
    }
  fclose (outfile);
  fclose (infile);
}