Exception thrown at 0x0F640E09 (ucrtbased.dll) in ConsoleApplication5.exe: 0xC0000005: Access violation writing location 0x014C3000?
<p>I just compiled this code, and it showed me this error:<br>
Exception thrown at 0x0F640E09 (ucrtbased.dll) in ConsoleApplication5.exe: 0xC0000005: Access violation writing location 0x014C3000. I literally have no idea what this error means as I've just been using C++ for a couple months, and I've also tried looking on any other websites to look for help, but I didn't find any. </p>

<p>For this code, I'm only allowed to use the c-string functions and the <code>&lt;cstring&gt;</code> library. I cannot use the string object or include the  library. I can also use helper methods/functions. </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;cstring&gt;
#include &lt;fstream&gt;
using namespace std;

class MyString {
public:

    //default constructor
    MyString();

    MyString(char* chars);

    //copy constructor
    MyString(const MyString &amp;);

    int length() const;

    //destructor
    ~MyString();

    //operator overloads
    char&amp; operator[](int index);
    friend MyString operator+(const MyString&amp; newWord, const MyString&amp; newWord2);
    MyString&amp; operator+=(const MyString&amp; newWord);
    friend ostream&amp; operator&lt;&lt;(ostream&amp; newWord, const MyString&amp; newWord2);
    friend istream&amp; operator &gt;&gt; (istream&amp; newWord, MyString&amp; newWord2);
    friend bool operator==(const MyString&amp; newWord, const MyString&amp; newWord2);
    friend bool operator!=(const MyString&amp; newWord, const MyString&amp; newWord2);
    friend bool operator&lt;(const MyString&amp; newWord, const MyString&amp; newWord2);
    friend bool operator&lt;=(const MyString&amp; newWord, const MyString&amp; newWord2);
    friend bool operator&gt;(const MyString&amp; newWord, const MyString&amp; newWord2);
    friend bool operator&gt;=(const MyString&amp; newWord, const MyString&amp; newWord2);

private:
    char* value;
    int size;
};

//default constructor
MyString::MyString() {

    value = 0;
    size = 0;
}

//copy constructor
MyString::MyString(const MyString&amp; newWord) {

    //perform a deep copy to copy each of the value to a new memory
    size = newWord.size;
    value = new char[size];

    for (int ii = 0; ii &lt; size; ii++) {
        value[ii] = newWord.value[ii];
    }
}

//constructor with an argument
MyString::MyString(char* chars) {

    size = strlen(chars);
    value = new char[size];
    for (int i = 0; i &lt; size; i++) {
        value[i] = chars[i];
    }

}

//find length
int MyString::length() const {

    return size;
}

//find the value of each index
char&amp; MyString::operator[](int index) {

    return value[index];
}

//operator + (concatenate)
MyString operator+(const MyString&amp; newWord, const MyString&amp; newWord2) {

    MyString concatenated;
    concatenated = strcat(newWord.value, newWord.value);
    return concatenated;

}

//operator += (append)
MyString&amp; MyString::operator+=(const MyString&amp; newWord) {

    char * newMemory = value;
    value = new char[strlen(value) + newWord.length() + 1];
    strcpy(value, newMemory);
    strcat(value, newWord.value);
    if (size != 0)
    {
        delete[] newMemory;
    }
    size = strlen(value);
    return *this;
}

//ostream operator
ostream&amp; operator&lt;&lt;(ostream&amp; newWord, const MyString&amp; newWord2) {

    newWord &lt;&lt; newWord2.value;
    return newWord;
}


//istream operator
istream&amp; operator &gt;&gt; (istream&amp; newWord, MyString&amp; newWord2) {

    const int MAX = 100;
    char* ptr = new char[MAX];
    newWord &gt;&gt; ptr;
    newWord2 = MyString(ptr);
    delete ptr;
    return newWord;
}

//all boolean operators
bool operator==(const MyString&amp; newWord, const MyString&amp; newWord2) {
    if (newWord.value == newWord2.value) {
        return true;
    }
    else {
        return false;
    }
}

bool operator!=(const MyString&amp; newWord, const MyString&amp; newWord2) {
    if (newWord.value != newWord2.value) {
        return true;
    }
    else {
        return false;
    }
}

bool operator&lt;(const MyString&amp; newWord, const MyString&amp; newWord2) {
    if (newWord.value &lt; newWord2.value) {
        return true;
    }
    else {
        return false;
    }
}

bool operator&lt;=(const MyString&amp; newWord, const MyString&amp; newWord2) {
    if (newWord.value &lt;= newWord2.value) {
        return true;
    }
    else {
        return false;
    }
}

bool operator&gt;(const MyString&amp; newWord, const MyString&amp; newWord2) {
    if (newWord.value &gt; newWord2.value) {
        return true;
    }
    else {
        return false;
    }
}

bool operator&gt;=(const MyString&amp; newWord, const MyString&amp; newWord2) {
    if (newWord.value &gt;= newWord2.value) {
        return true;
    }
    else {
        return false;
    }
}

//destructor to release memory
MyString::~MyString() {
    delete[] value;
}

void test_copy_and_destructor(MyString S) {
    cout &lt;&lt; "test: copy constructor and destructor calls: " &lt;&lt; endl;
    MyString temp = S;
    cout &lt;&lt; "temp inside function test_copy_and_destructor: " &lt;&lt; temp &lt;&lt; endl;
}

int main() {

    MyString st1("abc abc");
    MyString st2("9fgth");

    cout &lt;&lt; "Copy constructor , &lt;&lt; operator" &lt;&lt; endl;

    MyString  st3(st1);

    cout &lt;&lt; "st3: " &lt;&lt; st3 &lt;&lt; endl;

    test_copy_and_destructor(st2);

    MyString  st4;

    cout &lt;&lt; "operator + " &lt;&lt; endl;

    st4 = st3 + st2;

    cout &lt;&lt; "st4: " &lt;&lt; st4 &lt;&lt; endl;

    cout &lt;&lt; "st1 + st2: " &lt;&lt; (st1 + st2) &lt;&lt; endl;

    cout &lt;&lt; "operators  [ ] " &lt;&lt; endl;

    for (int i = 0; i &lt; st2.length(); i++)
        cout &lt;&lt; st2[i] &lt;&lt; " ";

    cout &lt;&lt; endl;

    cout &lt;&lt; "operators  += , ==, != " &lt;&lt; endl;

    st2 += st1;

    if (st3 == st1)
        cout &lt;&lt; "st3 and st1 are identical " &lt;&lt; endl;
    else cout &lt;&lt; "st3 and st1 are not identical " &lt;&lt; endl;

    if (st2 != st1)
        cout &lt;&lt; "st2 and st1 are not identical " &lt;&lt; endl;
    else cout &lt;&lt; "st2 and st1 are identical " &lt;&lt; endl;

    cout &lt;&lt; "operators  &lt; , &lt;=, &gt;, &gt;= " &lt;&lt; endl;

    if (st2 &lt; st1)
        cout &lt;&lt; "st2 &lt; st1 " &lt;&lt; endl;
    else cout &lt;&lt; "st2 is not less than st1 " &lt;&lt; endl;

    if (st1 &lt;= st2)
        cout &lt;&lt; "st1 &lt;= st2 " &lt;&lt; endl;
    else cout &lt;&lt; "st1 is not less than or equal to st2 " &lt;&lt; endl;

    if (st1 &gt; st2)
        cout &lt;&lt; "st1 &gt; st2 " &lt;&lt; endl;
    else cout &lt;&lt; "not (st1 &gt;  st2) " &lt;&lt; endl;

    if (st1 &gt;= st2)
        cout &lt;&lt; "st1 &gt;= st2 " &lt;&lt; endl;
    else cout &lt;&lt; "not (st1 &gt;=  st2) " &lt;&lt; endl;

    cout &lt;&lt; "operator &gt;&gt; " &lt;&lt; endl;

    //Open the data file
    ifstream input("A9_input.txt");
    if (input.fail()) {
        cout &lt;&lt; "unable to open input file A9_input.txt, Exiting..... ";
        system("pause");
        return 0;
    }
    MyString temp1;
    MyString temp2("aaa");
    input &gt;&gt; temp1;
    input &gt;&gt; temp2;
    cout &lt;&lt; "first element of input file: " &lt;&lt; temp1 &lt;&lt; endl;
    cout &lt;&lt; "second element of input file: " &lt;&lt; temp2 &lt;&lt; endl;
    input.close();

    cout &lt;&lt; "MyString says farewell....." &lt;&lt; endl;
    system("pause");
    return 0;
}
</code></pre>