Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

2 dimentional arrays

2 dimentional arrays

2 dimentional arrays

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

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

RE: 2 dimentional arrays

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close