title: append chars to get a string
body: <p>I have the following code in C:</p>
  
  <pre><code>    char *str = "Hello World";
      char *s = malloc(strlen(str));
      int i =0;
      for(;i&lt;strlen(str)-5;i++)
      {
          s += *(str+i);
      }
      printf(s);
  </code></pre>
  
  <p>It shows nothing. What I want is to get the substring of <code>str</code> stored in <code>s</code>.</p>
  
  <p>In Java I would do the following:</p>
  
  <pre><code>    String str = "Hello World";
      String s="";
  
      for(int i=0;i&lt;str.length()-5; i++)
          s+=str[i];
  
      System.out.println(s);
  </code></pre>
  
  <p>Or instead use the substring method. As <code>String s = str.substring(1,2);</code> for example.</p>
  
  <p>How can I achieve it?</p>