file2c.c revision 48478
1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@login.dknet.dk> wrote this file.  As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
8 *
9 * $Id: file2c.c,v 1.3 1997/02/22 19:55:01 peter Exp $
10 *
11 */
12
13#include <stdio.h>
14
15int
16main(int argc, char **argv)
17{
18    int i,j,k;
19
20    if (argc > 1)
21        printf("%s\n",argv[1]);
22    k = 0;
23    j = 0;
24    while((i = getchar()) != EOF) {
25	if(k++) {
26	    putchar(',');
27	    j++;
28	}
29	if (j > 70) {
30	    putchar('\n');
31	    j = 0;
32	}
33	printf("%d",i);
34	if (i > 99)
35	    j += 3;
36	else if (i > 9)
37	    j += 2;
38	else
39	    j++;
40    }
41    putchar('\n');
42    if (argc > 2)
43        printf("%s\n",argv[2]);
44    return 0;
45}
46