static int read_file_fgetc(char* filename) { FILE* fp = fopen_or_die(filename); char* irs = "\n"; int irs_len = strlen(irs); int bc = 0; while (TRUE) { char* line = read_line_fgetc(fp, irs, irs_len); if (line == NULL) break; bc += strlen(line); } fclose(fp); return bc; }
static int read_file_fgetc_fixed_len(char* filename, int do_write) { FILE* fp = fopen_or_die(filename); char* irs = "\n"; int bc = 0; while (TRUE) { char* line = read_line_fgetc(fp, irs); if (line == NULL) break; if (do_write) { fputs(line, stdout); fputc('\n', stdout); } bc += strlen(line); free(line); } fclose(fp); return bc; }