int main(int argc, char *argv[])
{
  FILE *f1 = fopen(argv[1],"r");
  FILE *f2 = fopen(argv[2],"r");
  unsigned int hash1[8] = {0};
  unsigned int hash2[8] = {0};
  char ch;

  while((ch=getc(f1)) != EOF)
      hash1[ch&7] |= 1 << (ch>>3);

  while((ch=getc(f2)) != EOF)
      hash2[ch&7] |= 1 << (ch>>3);

  for(ch = 0; ch < 256; ++ch)
    if (((hash1[ch&7]&hash2[ch&7]) >> (ch>>3)) & 1)
      printf("%c", ch);

  return 0;
}

On Aug 25, 9:12 am, Shrey Choudhary <choudharyshre...@gmail.com>
wrote:
> There are two files .. print the common characters in two files

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to