mirror of
https://github.com/SEPPDROID/Digital-Research-Source-Code.git
synced 2025-10-23 00:14:25 +00:00
1 line
767 B
C
1 line
767 B
C
/* -*-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);
|
||
|
||
}
|
||
|
||
|