Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Noob Needs help with 2 Dimensonal Array

Years of Service
User Offline
Joined: 31st Mar 2011
Posted: 1st Apr 2011 05:10
My problem is that I'm trying to compare the value of a 2 dimensonal array to a constant value here is a snipet.. Works in plain C++

The Code that gives the value for the 2 dimensonal array

Also I can tell you that current_player = 1 at this point and the row/columns are adjusted for the users convenience

The Code that Compares( without putting a wall of code up)
P1 is Constant and = 1

Any Help would be much appreciated
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 1st Apr 2011 17:00 Edited at: 1st Apr 2011 20:29
First off, I am new to C++ myself, but am willing to try and help. The following code initializes the rgiBoard array to the size of the SIZEOFBOARD variable. It then places four 'players' somewhere in the array. It then gets input from the user as to which player they want to find. It then searches the array to see where that player is located and prints it out on the screen.

I didn't really see where the variable, counter, was really used in the code. Since you are testing the value of counter, it should really be if(counter == 1). Still, since counter is increased every iteration, you are only going to fulfill the condition if rgiBoard[0][0] == 1. Upon the next iteration, counter will = 2. I hope I am making sense to you


I am using CodeBlocks with the MingW compiler, if it makes any difference. I hope this is helpful.

EDIT: Your question was technically to find a constant (like P1) in the array, which could easily be done by changing
. It would take away the ability to find players 2 - 4 though.

Years of Service
User Offline
Joined: 8th Jun 2010
Location: Serbia
Posted: 9th Jun 2011 18:43
Unhelpful Titles

Please do not simply write "Noob Question", "I am a newb", "One Noobie Question", "A question", "Please help", "This isn't working" or anything similar as the title of your post. We have a search facility, and meaningless titles do not help others find answers to their questions. It will also help you to get quicker responses if people have an idea of your thread content

Login to post a reply

Server time is: 2024-03-02 06:15:59
Your offset time is: 2024-03-02 06:15:59