void adde(int& v, char array[5])
{
if (v > 5) {
v = -1;
}
for (int k = 0; k < 5; k++) {
if (array[k] == 'C') {
array[k] = '-';
}
}
v++;
array[v] = 'C';
}
this is my function
int mov = -1;
char item[5];
for (int i = 0; i < 5; i++) {
item[i] = '-';
}
cout << "Initially " << endl;
for (int i = 0; i < 5; i++) {
cout << "[" << i + 1 << " ] ";
}
cout << endl;
for (int j = 0; j < 5; j++) {
cout << item[j] << " ";
}
cout << endl;
cout << "After Item 1, " << endl;
adde(mov, item);
for (int j = 0; j < 5; j++) {
cout << item[j] << " ";
}
cout << endl;
cout << "After Item 2, " << endl;
adde(mov, item);
for (int j = 0; j < 5; j++) {
cout << item[j] << " ";
}
cout << endl;
cout << "After Item 3, " << endl;
adde(mov, item);
for (int j = 0; j < 5; j++) {
cout << item[j] << " ";
}
cout << endl;
cout << "After Item 4, " << endl;
adde(mov, item);
for (int j = 0; j < 5; j++) {
cout << item[j] << " ";
}
cout << endl;
cout << "After Item 5, " << endl;
adde(mov, item);
for (int j = 0; j < 5; j++) {
cout << item[j] << " ";
}
cout << endl;
My code works fine till here. After the last item i want my cursor to point back to first index but shows weird Library Run time error After it runs this highlighted part of code cout << "After Item 6, " << endl;
adde(mov, item);
for (int j = 0; j < 5; j++) { cout << item[j] << " "; } }