Please note that scanf reads the standard input until and including the return key! The return key is a mandatory part of every single input!
However, you can check the return code from scanf: if successful, it returns the number of variables read. This number should be 1 for each correctly entered number, or 0 if no number was entered. So you could change your code to
int value;
while (scanf("%d", &value)) {
++i;
}
Like SA said, you need to make sure that your array is actually big enough, or you need to use a dynamic container such as a list. That's why I introduced a temporary variable for reading the value.