rendered paste body#include <stdio.h>#include <malloc.h>#define BUFLEN 65535int main(int argc, char** argv){ char *buf[BUFLEN]; size_t readlen = 0; unsigned nb = argc - 1; unsigned i; unsigned long total = 0; FILE **fds = (FILE **)malloc(sizeof(FILE *) * nb); if (nb < 1) { fprintf(stderr, "nothing to output to\n"); return 2; } for (i = 0; i < nb; i++) { if (!(fds[i] = fopen(argv[i+1], "wb"))) { fprintf(stderr, "can't fopen arg %u\n", i); return 3; } } fprintf(stderr, "reading... "); while ((readlen = fread(buf, 1, BUFLEN, stdin)) > 0) { total += readlen; fprintf(stderr, "%d bytes read. (%lu Kb)\n", readlen, total / 1024); fprintf(stderr, "writing... "); for (i = 0; i < nb; i++) { fprintf(stderr, "%d", i); if ((fwrite(buf, 1, readlen, fds[i])) != readlen) { fprintf(stderr, "fwrite error at arg %u\n", i); return 4; } } fprintf(stderr, ", done.\n"); if (feof(stdin) || ferror(stdin)) { break; } fprintf(stderr, "reading... "); } for (i = 0; i < nb; i++) fclose(fds[i]); free(fds); return 0;}