I have made a char
array, where I basically enter the number of rows and columns, and enter in the letters for each row and column, such as x
and y
. Basically, like an normal array but with letters. After I enter the letters and finish with the array, I want to enter 2 numbers to specify a specific char
in the array. For example, my array is 3x3. I fill my array with the characters x
and y
. After I do that, I enter 2 2
. At row 2 and column 2, the letter there is y
. So I want to print out y
.
Here is my code.
#include <iostream>
using namespace std;
int main()
{
int x,y;
cin>>x>>y;
char n[x][y];
for(int i=0;i<x;i++)
{
for(int j=0;j<y;j++)
{
cin>>n[i][j];
}
}
int a,b;
cin>>a>>b;
cout<<n[a][b];
}