blob: 2f2ea13ecc5b8e2a194da0cd2407392ff99b8f8d (
plain) (
blame)
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>
#include <string.h>
int main(int argc,char *argv[]) {
short in;
int i=0;
int width=argc>1?atoi(argv[1]):80;
char with=argc>2?argv[2][0]:' ';
char *line=argc>3?argv[3]:0;
if(width <= 0) width=80;
if(!line) {
while((in=fgetc(stdin)) != -1) {
if(in == '\n') {
for(;i%width || i == 0;i++) {
putchar(with);
}
i=-1;
}
i++;
putchar(in);
}
} else {
i=strlen(line);
}
if(i != 0 || line) {
if(line) fputs(line,stdout);
for(;i%width || i == 0;i++) {
putchar(with);
}
}
return 0;
}
|