Код должен прекращать обрабатывать текст на фразе Dragon flew away! однако этого не происходит почему-то
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ADDITIONAL_DATA 100
int main() {
char** text = (char**) malloc(sizeof(char*)* ADDITIONAL_DATA);
int cntSentence = 1;
int capasityText = ADDITIONAL_DATA;
for (int i = 0; i < cntSentence; i++)
{
text[i] = (char*) malloc(sizeof(char) * ADDITIONAL_DATA);
char symbol = getchar();
int idxSymbol = 0;
int capasitySentence = ADDITIONAL_DATA;
while(1)
{
text[i][idxSymbol] = symbol;
idxSymbol++;
if (symbol == '.' || symbol == ';' || symbol == '?')
break;
if (idxSymbol == capasitySentence-1)
{
capasitySentence += ADDITIONAL_DATA;
text[i] = (char*) realloc(text[i], sizeof(char)*capasitySentence);
}
symbol = getchar();
}
text[i][idxSymbol] = '\0';
cntSentence++;
if (strcmp(text[i], "Dragon flew away!") == 0)
break;
if (cntSentence == capasityText-1)
{
capasityText += ADDITIONAL_DATA;
text = (char**) realloc(text, sizeof(char*)*capasityText);
}
}
for (size_t i = 0; i < cntSentence; i++)
{
printf("%s\n", text[i]);
free(text[i]);
}
free(text);
return 0;
}