title: Check whether two strings are anagrams using C++
body: <p>The program below I came up with for checking whether two strings are anagrams. Its working fine for small string but for larger strings ( i tried : listened , enlisted ) Its giving me a 'no !'</p>
  
  <p>Help !  </p>
  
  <p></p>
  
  <pre><code>#include&lt;iostream.h&gt; 
  #include&lt;string.h&gt;
  #include&lt;stdio.h&gt;
  
  int main()
  {
      char str1[100], str2[100];
      gets(str1);
      gets(str2);
      int i,j;
      int n1=strlen(str1);
      int n2=strlen(str2);
      int c=0;
      if(n1!=n2)
      {
            cout&lt;&lt;"\nThey are not anagrams ! ";
            return 0;
      }
      else 
      {
           for(i=0;i&lt;n1;i++)
               for(j=0;j&lt;n2;j++)
                   if(str1[i]==str2[j])
                       ++c;
      }
      if(c==n1)
          cout&lt;&lt;"yes ! anagram !! ";
      else 
          cout&lt;&lt;"no ! ";
  
      system("pause");
      return 0;
  }
  </code></pre>