title: Insert hyphens after fifth character in C
body: <p>I have a char array, and I want to insert hyphens after every five characters. I have tried the following code but am looking for a better way to accomplish this task, what string function should I use, and how? Thanks. :D</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  int main()
  {
      char str[]="356a192b7913b04c54574d18c28d46e6395428ab";
      char buf[50];
  
      sprintf(buf, "%.5s-%.5s-%.5s-%.5s-%.5s-%.5s-%.5s-%.5s",str, str+5,str+10,str+15,str+20,str+25,str+30,str+35,str+40);
      printf("%s",buf);
      return 0;
  }
  </code></pre>