In the following lines of code, I am attempting to substitute the key string, in for the variable strings when it is found in a string. for instance if i had a string "hello VARIABLE world", the KEY value would be put in place of the VARIABLE value making the string "hello KEY world" instead of the original string. my theory for that was tokenize the string up to the first character of the variable (in the string) (newfirst), tokenize the variable characters (newtrash), and then tokenize the remainder of the string (newsecond). Then concatenize newfirst + key + newsecond. The issue is, myVariables[i].variable[0] and myVariables[i].variable[varlength - 1], are reading as chars into the strtok functions in the first two lines and the compiler is asking for a const char*. any idea how i could format the first and last values of these strings work in the strtok function?
SIMPLER WAY TO PHRASE THIS: how do i pass an individual char from a char array (user input so can NOT be hardcoded) as the deliminator character in the strtok function?
** to be clear this is not the whole program, just the lines of concern to the problem
strcpy(newfirst, strtok(testString, myVariables[i].variable[0]));
strcpy(newtrash, strtok( NULL, myVariables[i].variable[varlength - 1]));
strcpy(newsecond, strtok(NULL, "\n"));
strcat(newfirst, myVariables[i].key);
strcat(newfirst, newsecond);
struct variablePairs {
char variable[20];
char key[20];
};