I have a function that fills an array based on user input
The program works fine in this test case but it asks the user for one more number than needed.
void fill_array(char a[], int size)
{
char next;
const char SENTIEL ='.';
int index=0;
cin >> next;
while ((next !=SENTIEL) && (index < size))
{
a[index] = next;
index++;
cin >> next;
}
cout << a[0];
cout << a[1];
cout << a[2];
cout << a[3];
cout << a[4];
cout << a[5];
cout << a[6];
cout << a[7];
cout << a[8];
cout << a[9];
}
int main()
{
int const MAX=10;
char b[MAX];
fill_array(b,MAX);
}
this returns the correct numbers but it has one more to ask.