|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T t
Length: 1367 (0x557)
Types: TextFile
Names: »transpose.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen
└─⟦this⟧ »cph85dist/stat/src/transpose.c«
#include "unixstat.h"
PGM(transpose,Transpose Rows and Columns of Matrix File,5.0,3/4/85)
/* Copyright (c) 1982 Gary Perlman (see Copyright file) */
#define MAXCOLS 100
#define MAXLINES 100
char *A[MAXLINES][MAXCOLS];
/* OPTIONS */
char Format[10] = "%s\t"; /* format of fields */
initial (argc, argv) char **argv;
{
extern char *optarg;
extern int optind;
int errflg = 0;
int C;
ARGV0;
while ((C = getopt (argc, argv, "f:")) != EOF)
switch (C)
{
case 'f':
if (!number (optarg)) ERRNUM (optarg,format)
Format[0] = '%';
VOID strcpy (Format+1, optarg);
strcat (Format, "s ");
break;
default: errflg++; break;
}
if (errflg)
USAGE ([-f format])
ERROPT (optind);
checkstdin (Argv0);
}
main (argc, argv) char **argv;
{
char *array[MAXCOLS];
int c, l;
int ncols = 0;
int lines = 0;
int maxcols = 0;
char line[BUFSIZ];
initial (argc, argv);
while (gets (line))
{
ncols = parseline (line, array, MAXCOLS);
if (ncols == 0) continue;
if (lines == MAXLINES)
ERRMANY (lines, MAXLINES)
if (ncols > maxcols)
if (ncols > MAXCOLS)
ERRMANY (columns, MAXCOLS)
else maxcols = ncols;
for (c = 0; c < ncols; c++)
A[lines][c] = strdup (array[c]);
lines++;
}
for (c = 0; c < maxcols; c++)
{
for (l = 0; l < lines; l++)
printf (Format, A[l][c]);
putchar ('\n');
}
exit (0);
}