I'm a student and for one of our worksheets we've had to write a program that allows you to change a character in a two dimensional array and then print back the array afterwards, I'm struggling with getting it to print back with the changes added in. Below is the bit I believe I'm struggling with, any help would be appreciated. (p.s. I know I've done it wrong.) :)
cout << "Please enter row and column to modify: ";
while (true)
{
cin >> input_row >> input_col;
// Make sure user entered integers (and not something else)
if (!cin)
{
cout << "Hey! Two integers, please: ";
cin.clear();
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
}
// Make sure user's coordinates are inside the 2D array
elseif (input_row < 0 || input_row >= rows || input_col < 0 || input_col >= cols)
{
cout << "In [0," << (rows-1) << "] and [0," << (cols-1) << "]: ";
}
// Otherwise, everything is fine, so we can leave the loop and continue with the program.
elsebreak;
}
31 32 33 34
cout << "Enter the new value: ";
cin >> c;
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );