If you don't know exactly how many characters will be in the string, but have a hard upper limit, you can simply allocate enough space for that upper limit:
char tmpArray[1000];
Store the characters in there:
while((c=getchar())!=EOL)
{
tmpArray[count] = c;
count++;
}
and then after your loop finishes and you know how many characters there are (via count variable), you can allocate a new array with the correct amount and copy the temp string into it:
char actualArray[count];
for(int i = 0;i < count + 1;i++) {
actualArray[i] = tmpArray[i];
}
However this is not great as the large array cannot be freed up/removed from memory. It is probably a better idea to use malloc and a char* to do this:
char* tmpArray = malloc((sizeof(char)) * 1001);
while((c=getchar())!=EOL) {
tmpArray[count] = c;
count++;
}
char* actualArray = malloc((sizeof(char)) * count + 1);
strncpy(actualArray, tmpArray, count + 1);
free(tmpArray);
/***later in the program, once you are done with array***/
free(actualArray);
strncpy's arguments are (destination, source, num) where num is the number of characters to be transferred. We add one to count so that the null terminator at the end of the string is transferred as well.