Oh yea here is the updated code:
#include <fstream>
#include <string>
#include <iostream>
using namespace std;
int main()
{
// Declare and initialize the variables
string filename, Output_File, TXT_File, X, Original;
size_t i=0, Location, F_Array = 1;
char Array[50];
// Opens and reads the file which the user specifies
ifstream Original_Doc;
cout << "Please enter the file name\n";
cin >> filename;
Original_Doc.open(filename.c_str());
// If file cannot be found returns an error and exits
if (!Original_Doc)
{
cout << "Unable to open file Original_Doc";
exit (1);
}
// Reads the line in the file and saves it as TXT_File of type string.
getline(Original_Doc, TXT_File);
// Creates a copy of the original text before the program edits the text of the string.
Original = TXT_File;
// Moves the index through the array until when searching for a white space it returns a -1 for the position
for (i=0; F_Array != -1; i++)
{
Location = TXT_File.find(' ');
// Saves the text between cursor 0 and the white space as X.
X = TXT_File.substr(0, Location);
// Takes the first letter of the word saved as X.
X = X.substr(0,1);
// Erases the text before the white space so the next white space can be found in the string.
TXT_File = TXT_File.erase(0, Location+1);
// Creates a pointer called psz that points to the X string. This pointer allows the char array to be filled despite
// the fact that X is a string.
char* psz = _strdup(X.c_str());
Array[(This is triggering italics)I] = * psz;
F_Array = TXT_File.find(' ');
// When the program cannot find anymore whitespace, this means there is only one word left. This grabs the first
// character of that word and stores it in the respective cell in the array and then erases the rest of the string.
if (F_Array == -1)
{
i++;
Location = TXT_File.find_last_of(' ');
X = TXT_File.substr(0, Location);
X = X.substr(0,1);
TXT_File = TXT_File.erase(0, Location+1);
char* psz = _strdup(X.c_str());
Array[(This is causing italicsI] = * psz;
}
}
// Outputs the values in the array along with the original string for comparison.
cout << Array << endl << ": " << Original << endl;
// Closes the program.
return 0;
}