This file shows modifications to file lst10-6.c to check for sorted input files. The check is done by retaining the previous code value for each file, and testing that it is never larger than the next code. Change the declaration of load_record to: long load_record ( FILE *in_file, char name_buffer[], int whichfile, long prev_code ); Then add extra parameters to each call of the function: codeA = load_record(inA, nameA, 1, 0); codeB = load_record(inB, nameB, 2, 0); codeA = load_record(inA, nameA, 1, codeA); /*reload from file A*/ codeB = load_record(inB, nameB, 2, codeB); /*reload from file B*/ codeA = load_record(inA, nameA, 1, codeA); /*load record from file A*/ codeB = load_record(inB, nameB, 2, codeB); /*load record from file B*/ Then change the function heading of load_record to: long load_record ( FILE *in_file, char name_buffer[], int whichfile, long prev_code ) { Finally, insert this immediately after the end of the do...while loop: if (code < prev_code) { /*%%%*/ printf("Code %ld out of order on file %d.\n", code, whichfile); exit(1); }