Hi all,
I want to change following function to a "dynamic" fgets for string with unknown length and without any use of a buffer.Could someone give me an example with realloc please?
Code:
...
int ReadInputToTree(
WORD **DestTree,
size_t *Treecount,
FILE *Input)
{
int Status = SUCCESS;
char Buf[8192] = {0};
char *Word = NULL;
while(fgets(Buf, sizeof Buf, Input) != NULL)
{
Word = strtok(Buf, NONALPHA);
while(Status == SUCCESS&& Word != NULL)
{
Status = AddToTree(DestTree, Treecount, Word);
if(Status == SUCCESS)
{
Word = strtok(NULL, NONALPHA);
}
}
}
return (Status);
}
...