/* * cat.c * * Read several file names from the command line. * Concatenate these files and print the result to the standard output. */ #include // Copy the content of one file to another; assume that the files are open. // Return the number of characters copied int filecopy(FILE *in, FILE *out) { int c; for( ; (c = getc(in)) != EOF; ) { putc(c, stdout); } // TODO: finish the implementation (return the number of characters copied) } int main(int argc, char *argv[]) { int i; FILE *in; for (i=1; i< argc; i++) { in = fopen(argv[i], "r"); if (in == NULL) { fprintf(stderr, "Could not open file %s\n", argv[i]); return -1; } else { filecopy(in, stdout); fclose(in); } } return 0; }