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.
I can't figure out where I am going wrong.
Error:
Unhandled exception at 0x54E0F791 (msvcr110d.dll) in <filename>.exe: 0xC0000005: Access violation reading location 0x00000065
Here is my 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<10; j++)
strcat(sub[0],(char*)S[j-1]);
cout<<sub[0];