title: How to find a duplicate in an array? (C++)
body: <p>How can I find duplicates in my array? I put a max of 3 <code>Clients</code>. When I have 2 <code>Client</code>s, it updates the existing <code>Client</code>s with the incoming <code>Client</code>s, but when I have 3 <code>Client</code>s, it stops updating the existing <code>Client</code>s with the incoming <code>Client</code>s. The server still receives the data and the <code>Client</code> still sends the data, but it doesn't update it.</p>
  
  <p>I have looked at a few posts here about duplicates in an array but I'm unable to understand them. </p>
  
  <p>I'm thinking it has something to do with the <code>j &lt; 3</code> or the <code>i &lt; 3</code> but I'm not really sure. How can I properly detect duplicates and remove them?</p>
  
  <pre><code>  //Initialize Client
    Client clients[3]; //Max of 3 clients
    initClient(clients);
  
  
    while (1){
      for(int i = 0; i &lt; 3; i++) {//Existing Client
          for(int j = i; j &lt; 3; j++) {//Incoming Client
              if(j != i) {
                  if (clients[i].port == clients[j].port){ //If incoming port has the same port as existing, then update 
                      clients[i].x = clients[j].x;
                      clients[i].y = clients[j].y;
                      clients[i].channel = clients[j].channel;
                      clients[i].data = clients[j].data;
                      clients[i].len = clients[j].len;
                      clients[i].maxlen = clients[j].maxlen;
                      clients[i].status = clients[j].status;
                      clients[i].host = clients[j].host;
                      clients[i].port = clients[j].port;
                      clients[i].address = clients[j].address;
                      clients[i].present = clients[j].present;
  
                      //Remove the incoming client
                      clients[j].present = false;
                      clients[j].alive = false;
                      objectCount2--;
                  }
              }
          }
      }
     }
  </code></pre>