2
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 run.
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 one machine, 1º while never ends. And on another machine, I get a Segmentation fault. What may be happening?
I forgot to explain that CTRL+Z generates EOF... Good answer +1.
– AndersonBS