Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 dimentional arrays

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
HI
I am new, (no prizes for guessing)


If I have a 2 dimentional array say 10 X 10
and I pick 2 cordinates row and column
and I want the user to guess my choice eg

hit = table[1][7];

by inputting the row and column - but I want to be able to give them a clue each time tey get it wrong
either up, down, left, right, up-left, up-right, down-left
down-right

what I would like any suggestions on a code efficient way of checking the users input against and displaying the correct message

I have coded the program and it works fine but it is several lines long and includesabout 10 if statements

I havn't used pointers as I am only just beginng to figure out what they do but would also like suggestions as to how they would perhaps make the coding beter

Many Thanks
 
You can probably replace those If-statements with a Switch-statement, as a start. I am not sure why you think pointers would help you here? An array is really a pointer, it uses the index in the bracket to calculate the address of the specified value. Rob Marriott
rob@career-connections.net
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top