title: Empty character constant in C++
body: <p>I copied this code from a tutorial to play around with. However, I kept on getting an error that stated that I can't have any empty character constants. The tutorial was in <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#2008" rel="nofollow noreferrer">Visual Studio 2008</a>, and I am using <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#2013" rel="nofollow noreferrer">Visual Studio 2013</a>, so perhaps this is no longer valid, but I can't find any fix.</p>
  <p>Here is the code:</p>
  <pre class="lang-none prettyprint-override"><code>#include &quot;stdafx.h&quot;
  #include &lt;iostream&gt;
  
  class MyString
  {
      private:
          char *m_pchString;
          int m_nLength;
  
      public:
          MyString(const char *pchString=&quot;&quot;)
          {
              // Find the length of the string
              // Plus one character for a terminator
              m_nLength = strlen(pchString) + 1;
  
              // Allocate a buffer equal to this length
              m_pchString = new char[m_nLength];
  
              // Copy the parameter into our internal buffer
              strncpy(m_pchString, pchString, m_nLength);
  
              // Make sure the string is terminated
              // this is where the error occurs
              m_pchString[m_nLength-1] = '';
          }
  
          ~MyString() // Destructor
          {
              // We need to deallocate our buffer
              delete[] m_pchString;
  
              // Set m_pchString to null just in case
              m_pchString = 0;
          }
  
      char* GetString() { return m_pchString; }
      int GetLength() { return m_nLength; }
  };
  
  int main()
  {
      MyString cMyName(&quot;Alex&quot;);
      std::cout &lt;&lt; &quot;My name is: &quot; &lt;&lt; cMyName.GetString() &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  <p>The error I get is the following:</p>
  <blockquote>
  <p>Error 1 error C2137: empty character constant</p>
  </blockquote>