I am trying to print out each integer on a new line, given integers separated by whitespace from a user input. It stops printing after a specific number, lets say 84. For example
The user input is
20 -4 84 8
How could i use a while loop to print these out as
20
-4
84
i know about scanf("%d %d %d %d", a, b, c, d), However the input size would be unknown, such that there could be only 3 numbers or 7 numbers. So far i have:
#include <stdio.h>
int main(void)
{
int i = 0;
int x = 0;
scanf("%d", &x);
while (x != 84) {
print("%d\n", x[i]);
i++;
}
}
num? Do you want to store the previous numbers?