char s[ 100];
int I = 0;
while(scanf("%d ",& amps[i]),(a=getchar())! ='\n ')
{
i++;
}
for(int j = 0; j & lt= I; j++)
{
printf(" %d ",s[j]);
}
getchar();
I have tested the above code, which can meet your requirements, and (scanf ("%d ",&; s[i]),(a=getchar())! ='\n') Take a closer look at this code.
Note: When entering data, each entry is separated by a comma or a space. I hope it helps you.
Enter 1, 2, 3, 4, 5.
Output 1 2 3 4 5