So, I have a very strange error that I cannot understand. I run the loop and check the NULL value, then I assume to end the loop. But I get some problem with EXC_BAD_ACCESS after I have the following values (as you can see in the screenshot)
This is an additional piece of code that returns a char string
char *TKGetNextToken(TokenizerT *tk) { if((*tk).currentToken) return *(*tk).currentToken++; else return NULL; }
and actual structure
struct TokenizerT_ { char **currentToken; char **tokens; }tokenizer;
And this is what I have for my pointers:
char **words; words = (char **)malloc(sizeof(char*) * numberOfWords); for (int i = 0; i < numberOfWords; i++) words[i] = (char *)malloc(strlen(ts)+1); tokenizer.tokens = words; tokenizer.currentToken = words;
I do not know why this error can occur and why. Since we can have a pointer that points somewhere, or a NULL value ... 
source share