title: Automatically adjusting display types
body: <p>I am working on the <a href="http://gabrielecirulli.github.io/2048/" rel="nofollow noreferrer">"2048"</a> game project.</p>
  
  <p>When displaying the matrix, there are zeros as shown in the next figure:
  <img src="https://i.stack.imgur.com/TfBsw.png" alt="enter image description here"></p>
  
  <p>I want to get rid of the zeros in the table and just display the non-zero ints.
  So I added the following code to my existing "PrintMat" function:</p>
  
  <pre><code>void PrintMat(int a[4][4])
  {
      int b[4][4];
      int i, j;
  
      for (i = 0; i &lt; 4; i++)
      {
          for (j = 0; j &lt; 4; j++)
          {
              if (a[i][j] == 0)
              {
                  b[i][j] = ' ';
              }
              else
              {
                  b[i][j] = a[i][j];
              }
          }
      }
          printf("+--------------+--------------+--------------+--------------+\n");
  printf("|              |              |              |              |\n");
  printf("|   %5d      |   %5d      |   %5d      |   %5d      |\n", b[0][0], b[0][1], b[0][2], b[0][3]);
  printf("|              |              |              |              |\n");
  printf("+--------------+--------------+--------------+--------------+\n");
  printf("|              |              |              |              |\n");
  printf("|   %5d      |   %5d      |   %5d      |   %5d      |\n", b[1][0], b[1][1], b[1][2], b[1][3]);
  printf("|              |              |              |              |\n");
  printf("+--------------+--------------+--------------+--------------+\n");
  printf("|              |              |              |              |\n");
  printf("|   %5d      |   %5d      |   %5d      |   %5d      |\n", b[2][0], b[2][1], b[2][2], b[2][3]);
  printf("|              |              |              |              |\n");
  printf("+--------------+--------------+--------------+--------------+\n");
  printf("|              |              |              |              |\n");
  printf("|   %5d      |   %5d      |   %5d      |   %5d      |\n", b[3][0], b[3][1], b[3][2], b[3][3]);
  printf("|              |              |              |              |\n");
  printf("+--------------+--------------+--------------+--------------+\n");
  }
  </code></pre>
  
  <p>And the output become as shown in the following figure:
  <img src="https://i.stack.imgur.com/1CaZU.png" alt="enter image description here"></p>
  
  <p>I know what is wrong with it (I am using int type to display the characters). The problem is: How can I fix it? How can I get rid of the zeros?</p>
  
  <p>Thank you for your time!</p>