I need to create a way to read integers in the same input, and the amount of integers entered is random every time the program is executed.
I tried to perform the following algorithm:
#include <stdio.h>
#include <stdlib.h>
int main()
{
long int numero, i, vetor[100000];
i = 0;
while(scanf("%li", &numero) != EOF)
vetor[i++] = numero;
while(i > 0)
printf("%li ", vetor[i--]);
return 0;
}
However, on a machine, the 1st while never ends. And on another machine, I get a segmentation fault. What could be happening?