#include <string>
#include <cctype>
#include <fstream>
#include <iostream>
using namespace std;

int main () 
{
	system("color 0a");
	string filePath;
	string fileContents;
	string outputPath;
	int fileLength;
	char* fileAsArray;
	string correctness;
	string outputString = "";
	cout << "Path to input file: ";
	cin >> filePath;
	cout << "Path to output file (or \"over\" to use the input path): ";
	cin >> outputPath;
	if(outputPath.compare("over") == 0)
	{
		outputPath = filePath;
	}
	fstream fileToConv;
	fileToConv.open(filePath.c_str());
	fileToConv.seekg(0, ios::end);
	fileLength = fileToConv.tellg();
	fileToConv.seekg(0);
	fileAsArray = new char[fileLength];
	fileToConv.read(fileAsArray, fileLength);
	fileToConv.close();
	string fileAsString(fileAsArray, fileLength);
	cout << "The contents of the file appear to be:" << endl<< fileAsString << endl << "Is this correct? (y/n) ";
	cin >> correctness;
	if(correctness.compare("y") == 0 || correctness.compare("Y") == 0)
	{
		for(int i = 0; i < fileLength; i++)
		{
			char curChar = fileAsArray[i];
			if(toupper(curChar) != (int)curChar)
			{
				outputString = outputString + "[" + curChar + (char)toupper(curChar) + "]";
			}
			else
			{
				outputString = outputString + curChar;
			}
		}
		fstream fileToOutputTo;
		fileToOutputTo.open(outputPath.c_str());
		fileToOutputTo << outputString;
		fileToOutputTo.close();
		cout << "Conversion complete. Output written to " + outputPath << endl;
		system("PAUSE");
	}
	else
	{
		cout << "Oh, bother.";
	}
	return 0;
}