title: How to improve the output of this XOR?
body: <p>I am just trying to make a simple encryption that is obviously not secure at all. Everything is just fine but I am getting unprintable characters such as new line or nul. It becomes problem when decoding. How to solve this problem in this code?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
      int i;
      char text[1024];
  
      printf("ENTER SOME TEXT \n");
      fgets(text, 1024, stdin);
  
      for(i=0;i&lt;strlen(text)-1;++i)
      {
          if(text[i]!=32)
              text[i] ^= i;
      }
  
      printf("encoded text : %s",text);
  
      getch();
      return(0);
  }
  </code></pre>