When i get to the 9th number and enter anything other than an integer, it's printing a 0
Input integers separated by a space to store into Array A: 8 8 8 8 8 8 8 8 8 .
8 8 8 8 8 8 8 8 8 0
10
Input integers separated by a space to store into Array A: 1 2 3 4 5 6 7 8 9 a
1 2 3 4 5 6 7 8 9 0
Code:
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int i = 0, A[10], B[10];
int countA = 0, countB = 0;
printf("Please enter up to 10 integers separated by a space, when done hit any char in place of an integer\n");
printf("Input integers separated by a space to store into Array A: ");
fflush(stdout);
for(i=0; i<10; i++)
{
scanf("%d", &A[i]);
switch(A[i])
{
case 0:
// printf("%d ", A[i]);
break;
case 1:
// printf("%d ", A[i]);
break;
case 2:
// printf("%d ", A[i]);
break;
case 3:
// printf("%d ", A[i]);
break;
case 4:
// printf("%d ", A[i]);
break;
case 5:
// printf("%d ", A[i]);
break;
case 6:
// printf("%d ", A[i]);
break;
case 7:
// printf("%d ", A[i]);
break;
case 8:
// printf("%d ", A[i]);
break;
case 9:
// printf("%d ", A[i]);
break;
default:
goto ArrayB;
}
countA++;
}
ArrayB:
//printf("\n");
for(int z=0;z<countA;z++)
{
printf("%d ", A[z]);
}
return 0;
}