C function copies string to the same string but any repeated characters ':' replaced with one, but why there is 'Exception write access':
void shiftStr(char* str)
{
int len = strlen(str);
int c = 0;
int n1 = 0;
int j = 0;
std::cout << "string0:" << str << "\n";
for (int i = 0; i < len; i++)
{
if (str[i] == ':')
n1++;
else
n1 = 0;
if (n1 > 1)
continue;
str[j] = str[i];//<-----------Exception write access
j++;
}
std::cout << "string1:" << str << "\n";
}
int main()
{
char* str = (char*)"a:z::bb:::cc::::";
shiftStr(str);
}