The problem here resides with reading the char * nv
, which basically points to 0xCCCCCCCC
with the error Error reading characters of string
Already tried other fixes. There are more steps to this code but this is the simplified, overly-specific version:
char** splitStr(char* str, char separator, int sizeRet) {
char ** tot = new char *[sizeRet];
char * sep = new char[2];
sep[0] = separator;
sep[1] = '\0';
char * nv;
nv = strtok(str, sep);
int i = 0;
while (nv != NULL) {
tot[i] = nv;
nv = strtok(NULL, sep);
i++;
}
return tot;
}
Update
The code works in an online compiler perfectly. It doesn't work in Visual Studio 2017 for some odd reason. Will try eliminating some folders from the framework I have to use, and try again.