Files
Digital-Research-Source-Code/CPM OPERATING SYSTEMS/CPM 68K/cpm68k_pgms/utils/sortfl.c
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

1 line
767 B
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* -*-c,save-*- */
#include <stdio.h>
#define MAXLINES 1000
#define LINESIZ 128
main()
{static char *lines[MAXLINES],
line[LINESIZ];
register int linecnt;
register char *chp;
register int c;
char *calloc();
int strcmp1();
register int i;
linecnt = 0;
chp = &line[0];
while ((c = getchar()) != EOF) {
if (c != '\n')
*chp++ = c;
else {
*chp = '\0';
linecnt++;
lines[linecnt-1] = calloc(strlen(line)+1,1);
strcpy(lines[linecnt-1],line);
chp = &line[0];
}
}
qsort(&lines[0],linecnt,sizeof(char *),strcmp1);
for (i = 0; i<linecnt; i++)
printf("%s\n",lines[i]);
}
int strcmp1(a,b)
register char **a,**b;
{register int cmp;
cmp = strcmp(*a,*b);
return(cmp);
}