I have a program that repeatedly asks user input a line and stores them in an array. I know how to use dynamic memory allocation to make array if I can get a number of items to store at runtime. for example
char **array = (char**)malloc(numberOfItems * sizeof(char*));
but in my case, I do not know numberOfItems at runtime because I am getting input within a while loop which can be terminated by ctrl+D.
while(!feof(stdin)
{
array[i] = (char*)malloc(167 * sizeof(char));
}
Any help, please.