title: How to display duplicate characters in the string?
body: <p>I have written a program to display the duplicate character(s) in a string, but it displays the characters again if it comes more than 2 times. Any solution to find it exactly?</p>
  
  <p>//to find duplicate characters in the string........</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  int main()
  {
      int i,j;
      char ar[100];
      cout&lt;&lt;"enter string:";
      cin.getline(ar,100);
      for(i=0;ar[i]!='\0';i++)
      {
          for(j=i+1;ar[j]!='\0';j++)
          {
              if(ar[i]==ar[j])
              {  
                  cout&lt;&lt;ar[i]&lt;&lt;endl;
                  break;
              }
          }
      }
  
      system("pause");
      return 0;
  }
  </code></pre>