// Start with the inclusion of libraries #include <iostream> //The library of io functions #include <fstream> //The library of external stream functions #include <cstdlib> //The library for external errors #include <string> //The library for string functions #include <cmath> //The library of C math functions #include <iomanip> //Allows setting widths, etc. for I/O #include <stdlib.h> #include <stdio.h> #include<vector> using namespace std; // Define all of the prototypes for functions used in the program // Counts the number of unique letters seen int countunique(int *array, int size); // Creates the input file and formats it for use by the cipher section. void createinput(string ifile, string ofile); // Creates the encoded input file void createcipher(int key, string ifile, string ofile); // Finds and counts the number of digrams int digram(int *pointer, string ifile); // Counts the letter frequency in the encoded input file int lettercount(int*, string ifile, string ofile); // Finds the highest count in the singlton (or any other) array int singleton(int*, int size); // Trims an input file to the right size starting at an offset void trimfile(string ifile, string ofile, int offset, int size); // Begin the main function for testing int main(int argc, char* argv[]) { int count = 0; int second = 0; int singlefreq[26]; int *single = singlefreq; int delta; int loop; //The loop counter for arguments int final = 0; int totalcnt; int key = -1; //Sets the key value int len = 0; //The length to investigate for testing int off; //Holds the offset into the file double m; //Holds the metric error value char loopletter; float percent; string ifile1 = ""; string ofile1 = ""; string deflt = "c:\\dissertation\\ShiftandSubcipherC++files\\clean.txt"; string ifile2 = ""; string ofile2 = ""; //Holds selected file path names string cmdarg; //Holds the command line argument string stop = "l"; //Gives the stop condition, assumes l string reportfile = "c:\\dissertation\\test\\report.txt"; ofstream outs; //Declare an output stream for reporting int digramc[676]; //Set up the digram array int *two = digramc; //Point to the digram array int dicount = 0; //Holds the count of the number of digrams int total = 0; //Counts the total number of letters seen for analysis for (loop = 1; loop<argc; loop++) //Decide if we have arguments or must use defaults { if (!argv[1]) { // cout << "No argument found.\n"; ifile1 = deflt; } else { cmdarg = argv[loop]; if (cmdarg == "-k") { loop++; key = atoi(argv[loop]); cout << "key = " << key << endl; } if (cmdarg == "-l") { loop++; len = atoi(argv[loop]); cout << "Run for " << len << " characters.\n"; } if (cmdarg == "-m") { loop++; m = atof(argv[loop]); cout << "Run until and error of " << m << "\n"; } if (cmdarg == "-off") { loop++; off = atoi(argv[loop]); cout << ...