I couldn't figure out why but this is my code :
char expression[256] = {};
cin >> expression;
cout << endl;
int** variableTable = NULL;
int numOfVals = getNumberOfVariables(expression);
variableTable = static_cast<int**>(calloc(numOfVals, sizeof(int*)));
for (int i = 0; i < numOfVals; i++)
{
variableTable[i] = static_cast<int*>(calloc(2, sizeof(int)));
}
fillPromoterTable(expression, variableTable, numOfVals);
this is the fillPromoterTable
void fillPromoterTable(const char* expression, int** variableTable, int numOfVals)
{
char promoter[15] = {};
char *token;
char* expCpy = pcstrdup(expression);
for (int i = 0; numOfVals; i++)
{
token = strtok(expCpy, "+-*/");
int nLen = istrlen(token);
for (int j = 0; j < nLen; j++)
{
if (isdigit(token[j]))
promoter[j] = token[j];
if (isalpha(token[j]))
break;
}
variableTable[i][0] = atoi(promoter);
memset(promoter, '\0', 15);
token = strtok(NULL, "+-*/");
}
free(token);
free(expCpy);
}
in this line :
variableTable[i][0] = atoi(promoter);
I get an error saying I'm trying to write to address 0xFDFDFDFD I couldn't figure out why it happens I could use some help.