title: Binary Search in C
body: <p>I implemented a search function of elements of the list that it was a binary search returns the index of the element found.  My curiosity is to have a method of the binary search you could print all occurrences of the element in the list.</p>
  
  <p>Below is the code</p>
  
  <pre><code>int Binary_Search(int *array, int chave , int N) {
      int inf = 0; 
      int sup = N-1; 
      int meio;
      while (inf &lt;= sup) {
          meio = inf + (sup-inf)/2;
          if (chave == array[meio])
              return meio;
          else if (chave &lt; array[meio])
              sup = meio-1;
          else
              inf = meio+1;
      }
  
      return -1;   
  }
  </code></pre>
  
  <p>part of the other source</p>
  
  <p>How could I make this code snippet only print occurrences duplicated?</p>
  
  <pre><code>else {
      Imprime_Struct(Tabinvertida_Fornecedor[aux]-&gt;info);
      aux=aux+1;
      while (aux != i) {
          if (strcmp(chave, TabName[aux]-&gt;info.name)==0)
              Print_Struct(TabName[aux]-&gt;info);
          aux++;
      }
  }
  </code></pre>