title: Adding array element into an array in a needed position
body: <p>What I need to do is to receive an array a number and the index.And I try to create a function *<em>insertc(char <em>str, char c, int n)</em></em>  but it seems that the loop has some problems that it couldnot to append and somehow export an irregular row.<a href="https://i.stack.imgur.com/CiLCx.png" rel="nofollow noreferrer">Like this.</a>Help me!</p>
  <pre><code>#include&lt;stdio.h&gt;
  char str[10];
  void insertc(char *str, char c, int n)
  {   int m=sizeof(str)+1;
      char *p=str;
      for(int i=m-1;i&gt;n-1;i--)
      str[i+1]=str[i];
      *(p+n-1)=c;
  }
  int main(){
      char c;int a;
      gets(str);
      scanf(&quot;%c\n%d&quot;,&amp;c,&amp;a);
      insertc(str,c,a);
      puts(str);
      return 0;
  }
  </code></pre>