title: Strange problem with variable in C program
body: <p>This code is to change decimal &quot;n&quot; to binary that I wrote like this:</p>
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  
  int main(){
      char str[] = &quot;&quot;;
      int a = 5;
      int n = 5;
      while(n &gt; 0){
          if (n % 2 == 0) {
              strcat(str,&quot;0&quot;);
          } else {
              strcat(str, &quot;1&quot;);
          }
          n = n / 2;
      }
      strrev(str);
  
      printf(&quot;%s&quot;, str);
      return 0;
  }
  </code></pre>
  <p>The problem here is, when I tried to debug and see the variable changing, the &quot;a&quot; changed in a very strange way, although I don't do anything to &quot;a&quot;. Why is it like that?</p>