I'm trying to get unlimited input from user, using realloc. this is what i've done so far:
int getCharactersFromUser(char* arr,char terminator)
{
char c = getch();
int length =0;
while(c!=terminator)
{
arr = realloc(arr, sizeof (arr)*(++length));
arr[length-1]=c;
c = getch();
}
return length;
}
i call this method with an arr like this: char *unknownArr = calloc(0,sizeof *unknownArr);
int length = getCharactersFromUser(&unknownArr,TEMINATOR_FOR_LIST);
here TEMINATOR_FOR_LIST
is eof