2D Array using int variable to find

I am trying to use two for loops to find the location of a character in a 4x4 array, and store the location in int row col variables, and read out the character in array [col][row], but the it's not letting me use a variable for both. Any idea why? I don't have a copy of the code with me but will post later.

Something in that logic:
Q: "I want to find 'X' and then print what is in the place, where the 'X' is."
A: Why search and not just print 'X'? The place that has 'X' by definition has 'X'.

... screams: "incomplete information".

Of course, there is the possibility that none of the 16 characters is 'X'. How are you going to read that?


Please show the code (neatly in tags), for without our guesses go too wild.
If X is in 2nd row 3rd col, I want to print whatever is in the 3rd row 2nd col. Switch the col and row.
1
2
3
4
5
6
7
8
int col;
int row;

// do the search
// if not found, do something

std::cout << "Found on row=" << row << " col=" << col << '\n';
std::cout << "I'm interested in row " << col << " and col " << row << '\n';
Topic archived. No new replies allowed.