// // pratice.c // Made this for coding practice // CSSE 132 // // ANSWER KEY // #include <stdio.h> void cat(FILE* f) { char block[512]; int len = 0; while(!feof(f)) { len = fread(block, 1, 512, f); len = fwrite(block, 1, len, stdout); } } int main(int argc, char** argv) { // from part 2.3 //printf("Got %d arguments, last one is %s\n", argc-1, argv[argc-1]); // Need to have a file to open. if (argc < 2) { return 1; } FILE* f = fopen(argv[1], "r"); // fopen returns NULL if it fails (like if the file is missing). if (f == NULL) { return 1; } cat(f); fclose(f); return 0; }