title: Saving numbers and calculations in a string by using 2D array give unexpected outputs
body: <p>So here is a simple code that saves numbers and calculations one by one.
  Basically what I want to do is saving all numbers and calculations in one 2D array by using if/else if</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  int main()
  {
      char str1[100];
      char newString[100][100];
      char temp[100];
      int i, j, ctr, count = 0;
      gets(str1);
  
      j = 0;
      ctr = 0;
      for (i = 0; i &lt;= (strlen(str1)); i++)
      {
          // if space or NULL found, assign NULL into newString[ctr]
          if (str1[i] == ' ' || str1[i] == '\0')
          {
              newString[ctr][j] = '\0';
              ctr++; //for next word
              j = 0; //for next word, init index to 0
          }
          else if(str1[i]=='+'||str1[i]=='-'||str1[i]=='*'||str1[i]=='/'){
              ctr++; //for next word
              j = 0; //for next word, init index to 0
              newString[ctr][j] = str1[i];
              ctr++; //for next word
              j = 0; //for next word, init index to 0
          }
          else
          {
              newString[ctr][j] = str1[i];
              j++;
          }
      }
      for (i = 0; i &lt; ctr; i++)
      {
          printf(&quot;%s\n&quot;, newString[i]);
      }
      return 0;
  }
  </code></pre>
  <p>When I put <strong>'143 + 2/3 + 23'</strong> , what I expected is</p>
  <pre><code>143
  +
  2
  /
  3
  +
  23
  </code></pre>
  <p>But what I got is</p>
  <pre><code>143
  
  +
  
  2
  /
  3
  
  +
  
  23
  </code></pre>
  <p>There are some spaces between elements... can anyone help me what makes this kind of problem?</p>