title: How to XOR two byte streams in C?
body: <p>I've been reading through SO for the past couple of days trying to figure this out, I am stumped.  I want to read in two 32 bit byte arrays (from stdin, input will be hex) and xor them, then print the result.</p>
  
  <p>So far I've tried using scanf, fgets, and gets.  My thought was to read the large hex numbers into a char buffer and perform the xor in a for loop until I hit an EOL (with fgets) or a null terminator.  So far my output is not even close.  I tried lots of variations, but I will only post my latest fail below.  The challenge I've been trying to complete is: <a href="http://cryptopals.com/sets/1/challenges/2/" rel="nofollow">http://cryptopals.com/sets/1/challenges/2/</a></p>
  
  <p>I am trying it in C because I'm really trying to learn C, but I'm really getting frustrated with none of these attempts working.</p>
  
  <pre><code>#include &lt;stdio.h&gt; 
  #include &lt;math.h&gt;
  
  int main()
  {
      char buff1[100];
      char buff2[100];
      char buff3[100];
      int size = sizeof(buff1);
  
      puts("Enter value\n");
      fgets(buff1, size, stdin);
      puts(buff1);
      puts("Enter value\n");
      fgets(buff2, size, stdin);
      puts(buff2);
  
      for (int i = 0; i != '\n'; i++) {
          buff3[i] = buff2[i] ^ buff1[i];
          printf("%x", buff3[i]);
      }
  
      return 0;
  }
  </code></pre>