Q:

Dynamic Memory Allocation for Unknown Number of Inputs (without realloc)

So I am writing a program that takes in any number of integers from stdin and I need to dynamically allocated enough space for the inputs.
This wouldn't be a problem for me except for two reasons:
1) You don't specify how many inputs there will be so I can't just use calloc along with the number of inputs without already reading through them and counting.
2) I can't use realloc to grow the size of the array.
Is there some way to count how many integers are in the input and then read through them again and put them into an array?

A:

Use a linked-list. You can allocate new space as needed without moving the existing data.

Is there some way to count how many integers are in the input and then read through them again and put them into an array?

The only way I can think of to do that is to copy into a tmpfile() as you count, then rewind() the file and read again. 

