#include <stdio.h>

void filecopy(FILE *ifp, FILE *ofp) {
    int c;
    while ((c = fgetc(ifp)) != EOF) fputc(c, ofp);
}

int main(int argc, char *argv[]) {
    FILE *ifp;
    char *name = argv[0];

    if (argc == 1) { /* 没有参数，从标准输入复制到标准输出 */
        filecopy(stdin, stdout);
        return 0;
    }

    while (*++argv != NULL) 
        if ((ifp = fopen(*argv, "r")) == NULL)
            printf("%s, can't open input file: %s\n", name, *argv);
        else {
            filecopy(ifp, stdout);
            fclose(ifp);
        }

    return 0;
}


