// From the software distribution accompanying the textbook // "A Practical Introduction to Data Structures and Algorithm Analysis, // Third Edition (C++)" by Clifford A. Shaffer. // Source code Copyright (C) 2007-2011 by Clifford A. Shaffer. // This program generates test files for external sorting algorithms. // Output files can be of any multiple of the 4096 byte block size. // The data records are logically a two byte (short int) key value followed // by a two byte (short int) data value. // The values output by this program can either be "binary" or "ascii". // "Binary" files have key and data values each in the range 1 to 30,000. // "Ascii" files have their data and key values selected so that they are // easy to read and test. The data value prints in ascii as two spaces. // The key value prints in ascii as a space and then a capital letter (A-Z). // This makes it simple to tell if the sorting algorithm is working. #include "book.h" #include #include #include using std::fstream; using std::ios; // A block is 4096 bytes, or 1024 logical records #define NumRec 1024 typedef int E; int main(int argc, char** argv) { int filesize; E Array[NumRec]; int i, j; fstream myfile; bool Ascii; // True if ASCII option, false if binary option. if (argc < 4) { cout << "Usage: genfile