Hi
I only have a simple query I am relatively new to c++ and I am trying to create 10 randomly placed items in a grid. I've used the following for loop:

for(int x=0; x<10; x++)
    {              
            array[n1][n2] = aliveG;  
    }

and it only displays the item once, n1 and n2 are 2 random numbers.

Thanks in advance!

So if you say that n1 and n2 are 2 random values, there is no line of code inside the for loop to tell them to change their values so they always remain the same, you can't expect they will change randomly out of nowhere.

Hint: If you want to assign random values for the grid positions, put some code in the for loop so the values of n1 and n2 change each time the for loops.

Thank you very much for the help that has just sorted my problem! :)

Anytime! Glad I could help :).

Edit: If your question is fully answered please mark the thread as solved thanks! :).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.