This function takes a pointer to pointer argument, or, a pointer to a character string and does two things:
1) Returns the first character of this string
2) Makes the pointer point to the next character
This means next time it is called, it always returns the next character.
Code:
char getToken(char **inputString){
char returnCharacter = **inputString;
*inputString = *inputString + 1; //How do we fix this memory leak???
return returnCharacter;
}
The problem? In this functions caller, input string has been malloc()'ed.
If I understand correctly, every time I shift the pointer in getToken, Im losing reference to Heap memory and therefore lose any way to free it in future. How can I free it in this function?