title: How to split string in c?
body: <p>I am trying to split string in two parts using space as a separator. I had tried the below code but i got wrong result.</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  void main()
  {
      char str_1[5], str_2[5], my_str[] = "hello world";
  
      //storing hello in str_1.
      for (int i = 0; i &lt;= 4; ++i)
          str_1[i] = my_str[i];
      puts(str_1);
  
      //storing world in str_2.
      for (int i = 6, j = 0; i &lt;= 10; ++i, ++j)
          str_2[j] = my_str[i];
      puts(str_2);
  }
  </code></pre>
  
  <p>Expected output: </p>
  
  <pre><code>hello
  world
  </code></pre>
  
  <p>Getting output:</p>
  
  <pre><code>hello
  worldhello
  </code></pre>