If you do not know the number of values you will be reading, you will have to dynamically allocate some memory, then allocate some more when you need it, and finally deallocate anything you are no longer using.
You have also need to check the return value of scanf to determine when to stop your loop. Here is an example.
#include <stdio.h>
#include <stdlib.h>
int main() {
// You could reallocate to allow for one extra item at a time, an
// fixed chunk at a time (as shown here), or some other strategy such
// as doubling the allocation size at each realloc
#define CHUNK_SIZE 20
int n = 0, n_chunks = 0;
int *arr = 0;
do {
if (n == (n_chunks * CHUNK_SIZE)) {
++n_chunks;
arr = realloc(arr, sizeof arr[0] * n_chunks * CHUNK_SIZE);
if (!arr) { return 1; } // Memory allocation can fail, so check it
}
} while (1 == scanf("%d", &arr[n]) && ++n);
// Trim any excess
arr = realloc(arr, sizeof arr[0] * n);
if (!arr && n > 0) { return 1; }
// Print the values we read in
printf("Read %d value%s\n", n, (n == 1) ? "" : "s");
for (int x = 0; x < n - 1; ++x) {
printf("%d,", arr[x]);
}
if (n > 0) { printf("%d\n", arr[n - 1]); }
// At the end of the program, free the memory we allocated
free(arr);
arr = 0;
return 0;
}