Using pointers to compare multiple values?

Hi all,

I'm constructing a Battleships game, and I have a "srand" function for assigning random values to the computer's ships. Because I'm working in small parameters, I often get duplicate values which obviously doesn't help :P
I've got the following five integers for the location of the computer's ships;

1
2
3
4
5
    int compAirCarr;
    int compBatt;
    int compDest;
    int compSub;
    int compPatrol;


I'm wondering if it's possible to compare each of the values without having to do a long "IF" statement such as:
 
if (compAirrCarr == compBatt || compAirCarr == compDest...)

where I would have 25 different comparisons.

I'm thinking that something along the lines of having a pointer like
*computerPick
to iterate a comparison, to check for duplicates?

I would appreciate any suggestions or input you knowledgeable people have :)
Regards,
did u try to use time () function from <ctime>

srand (time (0) );
Last edited on
thank you sasanet, that seems to have worked :) much appreciated
Topic archived. No new replies allowed.