c++ crashes on writing public variable
<p>I wrote a simple test program in c++ but why does this crash on:</p>

<pre><code>s[i] = s[i] - 'a' + 'A';
</code></pre>

<p>with the exception: Access violation writing location 0x01327808</p>

<pre><code>#include "stdafx.h"
#include &lt;iostream&gt;

using namespace std;

class String
{
public:
  char *s;
  int len();
  void upper();

  String(char*);

};

String::String(char*x)
{
  s = x;
}

int String::len()
{
  return strlen(s);
}

void String::upper()
{
  for (int i = 0; i &lt; len(); i++)
  {
    if (s[i] &gt;= 'a' &amp;&amp; s[i] &lt;= 'z')
    {
      cout &lt;&lt; s[i] &lt;&lt; endl;
      s[i] = s[i] - 'a' + 'A';
    }
  }
};

int main()
{
  String s("test");
  s.upper();

  cout &lt;&lt; s.len() &lt;&lt; endl;
  cout &lt;&lt; s.s &lt;&lt; endl;

  system("pause");
}
</code></pre>
