I am having hard time understanding what the problem is with my code here. Basically I have a map that contains Key objects as the key, and Block* as the value. The point of this for loop is to print out the values that the key contains on to the console in the form of a game board. However it is only printing one role, in a infinite loop. the variable r never gets incremented for some reason. if you guys could help that would be great. Thanks in advance!

for (int r=0; r<rows; r++){
            for (int c =0; c<columns; c++){
                std::string name = "__ ";
                for (std::map <Key, Block*>::iterator it = blocks.begin(); it != blocks.end(); ++it){
                    Key key = it->first;
                    int x = key.getX();
                    int y = key.getY();
                    if (r=y && c==x){
                        Block *block = it->second;
                        name = block->getBlockName();
                    else {
                        name = "__ ";
                std::cout<<name;//print one row
            //start new row

Edited 3 Years Ago by Nick Evan: Fixed formatting

Simple typo:

if (r=y && c==x){

should be:

if (r == y && c == x){

(notice the double = signs.

**Please use code-tags in the future.

Edited 5 Years Ago by mike_2000_17: n/a

ahh i c thanks alot !! that solves the problem dumb mistake on my part

This question has already been answered. Start a new discussion instead.