title: Read Access Violation _First was nullPtr
body: <p>I have a <strong>default constructor</strong>, <strong>copy constructor</strong>, <strong>destructor</strong>, <strong>assignment</strong> <strong>operator</strong>, <strong>length</strong>, and <strong>string</strong> functions.  When I call the copy constructor and try to print the value of the new char*, I get a Read Access Violation _First was nullptr.  The debugger shows iosfwd code and breaks at the error, but I have no clue what this means.  Any help would be awesome.
  This is where the debugger shows the error.</p>
  
  <pre><code>  static size_t __CLRCALL_OR_CDECL length(const _Elem *_First)
          {   // find length of null-terminated string
          return (*_First == 0 ? 0 // &lt;- this line
              : _CSTD strlen(_First));
          }
  </code></pre>
  
  <p>These are my functions (also not that we were not allowed to use STRCPY)</p>
  
  <pre><code> MyString::MyString() { //default constructor
      string = new char[6];
      int i = 0;
      for (i; i &lt; strlen(string); i++) {
          string[i] = NULL;
      }
      string[i] = '\0';
  }
  
      MyString::MyString(const MyString &amp;s) { //copy constructor
      char* string = new char[strlen(s.string) + 1];
      int i = 0;
      for (i; i &lt; strlen(s.string); i++) {
          string[i] = s.string[i];
      }
      string[i] = '\0';
  }
  
      MyString::~MyString() { //destructor
      delete[] string;
      string = NULL;
  }
  
      MyString&amp; MyString::operator=(const MyString&amp; s) { //assignment operator
      char* temp = new char[strlen(s.string) + 1];
      int i = 0;
      for (i; i &lt; strlen(s.string); i++) {
          temp[i] = s.string[i];
      }
      temp [i] = '\0';
      delete[] string;
      string = temp;
      return *this;
  }
  
      size_t MyString::length() const { //length of string
      return strlen(string);
  }
  
      char* MyString::cString() { //string
      return string; 
  }
  
      int main(int argc, const char * argv[]){
      MyString s;
      std::cout &lt;&lt; "Empty: '" &lt;&lt; s.cString() &lt;&lt; "'\n";
      s = "hello";
      std::cout &lt;&lt; "After operator=: '" &lt;&lt; s.cString() &lt;&lt; "'\n";
      {
          MyString t(s);
          std::cout &lt;&lt; "After copy: '" &lt;&lt; t.cString() &lt;&lt; "'\n";
          s = t;
      }
  }
  </code></pre>