I have an assignment that asks a user to input at most 10 integers to be stored into an array. The code i have now, i believe wants exactly 10 integers.
How can i manipulate the input of the array (scanf) to stop inputting and move on after only 4 inputs. IE: 1 2 3 4. then move on to next array.
Code:
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int i = 0, A[10];
printf("Input a set of up to 10 integers separated by a space to store in Array A: ");
fflush(stdout);
for(i = 0; i<10; i++)
{
if((scanf("%d"), &A[i]) >= 0)
{
scanf("%d", &A[i]);
printf( "%d ", A[i]);
}
else
{
break;
}
}
return 0;
}