// Name: msglm // Date: // Program Name: // Description: #include #include #include using namespace std; // Named constants int ARR_SIZE = 50; //Personally, i'd pass this as an env var or a flag int main() { //Variable declaration string tmpArr[ARR_SIZE]; //Probably could pass through the file first to get the size first and declare this, but that's past this program's scope. int epoch = 0; //both counts up and is the length of the array. //Vars necessary to invert an array int start = 0; string tmp; int end = 0; //It's a shame this isn't STDIN and STDOUT ifstream inFile; ofstream outFile; // User input if (inFile) { inFile.open("in.txt"); outFile.open("out.txt"); //Read the line, put it at the epoch in the array, also check if EOF. if EOF, abort. while(getline(inFile, tmpArr[epoch]) && inFile.peek() != EOF) { cout << tmpArr[epoch] << endl; outFile << tmpArr[epoch] << endl; epoch = epoch + 1; } //Epoch is assumed to be the length of the variable at this point, so will use accordingly end = epoch; //exchange the positions of the first and last var in an array while slowly moving to the center //i.e //on first pass of the while look will turn [1, 2, 3, 4] into [4, 2, 3, 1] //and the second will turn [4, 3, 2, 1] // //I opted to use this algorithm to not create any more data while (start < end) { tmp = tmpArr[start]; tmpArr[start] = tmpArr[end]; tmpArr[end] = tmp; start = start + 1; end = end - 1; } //finally, output the reversed array and dump it into a file for(int i=0;i. */