title: Access violation reading Location (Visual Studio C++)
body: <p>I am trying to form substrings of a given string, so that both string and substring are dynamically allocated, substring is 2D array as it will contain multiple substrings.</p>
  
  <p>I can't figure out where I am going wrong.</p>
  
  <p>Error: </p>
  
  <pre><code>Unhandled exception at 0x54E0F791 (msvcr110d.dll) in &lt;filename&gt;.exe: 0xC0000005: Access violation reading location 0x00000065
  </code></pre>
  
  <p>Here is my Code:</p>
  
  <pre><code>char **sub = new char* [10];
  sub[0] = new char [10];
  strcpy(sub[0],"");
  
  char *S = new char[10];
  strcpy(S,"");
  cin.getline(S,10);
  
  for(int j = 2; j&lt;10; j++)
      strcat(sub[0],(char*)S[j-1]);
  
  cout&lt;&lt;sub[0];
  </code></pre>