/* * Copy text from one flle to another (filenames "hardcoded" for now). */ #include void echo(void); int main(void) { FILE * infile = fopen("in.txt", "r"); if (infile == NULL) { fprintf(stderr, "cannot open input file\n"); return 1; } FILE * outfile = fopen("out.txt", "w"); if (outfile == NULL) { fprintf(stderr, "cannot open output file\n"); return 1; } int inchar; int count = 0; while ((inchar = fgetc(infile)) != EOF) { count += 1; fputc(inchar, outfile); } fclose(infile); fclose(outfile); printf("%d chars echoed\n", count); return 0; }