I am having trouble using cin
to enter multiple single digits that are separated by a comma.
So far i have tried using this
int size = 8;
// = {2,5,6,7,8,3,1,4} the values I wish to input
int nums[8];
cin >> nums [0] >> nums [1] >> nums [2] >> nums [3] >> nums [4] >> nums [5] >> nums [6] >> nums [7];
for (int i=0; i < 8; i++) {
cout << nums[i] << " ";
}
When I input 2,5,6,7,8,3,1,4
, only 2 0 0 0 0 0 0 0
is outputted.
Is there any way to fix this by using cin
?