I am having some difficulty's locating an issue within some code I am working on.
It breaks when it runs the "if (AIwords->name == NULL)"
// This is the struct which is located in the header(.h)
struct AIstruc_word
{
char *name;
bool controlStatement;
struct AIstruc_word *next;
};
// This is the struct that contains the sub struct
struct AIstruc_sentence
{
struct AIstruc_word word;
....
....
....
// This is the function which is crashing the program
int AI_sentenceProc(struct AIstruc_sentence *AIdatabase, char *word)
{
struct AIstruc_word *AIwords = (struct AIstruc_word*)&AIdatabase->word;
...
...
...
for (; ; AIwords = AIwords->next)
{
printf("%d\r\n", iPosition++);
/// When we reach an empty word slot
if (AIwords->name == NULL)
{
/// Break out of this 'do{}while()' loop.
break;
}
if (AIwords->next == NULL)
{
AIwords->next = (struct AIstruc_word *)calloc(1, sizeof(struct AIstruc_word));
break;
}
}
...
...
...
// This is the code that passes the parent struct
int AI_sentenceRequestProcess(.....)
{
struct AIstruc_sentence AIdatabase;
....
....
AI_sentenceProc(&AIdatabase, quickBuffer);
Does anyone have an idea what I'm doing wrong here....
Help would be greatly appreciated