title: How to give a size using realloc?
body: <p>I want to give a random size to <code>pointer</code> and I want to add some elements to the <code>pointer</code>. I want to give place to the <code>pointer</code> enough size. For example, if I have <code>10</code> elements in <code>pointer</code>, I want to give place <code>40</code> <code>byte</code> to <code>pointer</code>. But when I looked to my code, initially I gave so much size for the element.
  I want to see as an output:</p>
  <p>67
  11
  64
  7</p>
  <p>67
  11
  64
  7
  23
  81
  88
  35
  12
  5
  7</p>
  <p>The size of memory=40</p>
  <pre><code>    #include &lt;stdio.h&gt;
      #include &lt;stdlib.h&gt;
      int main() {
          
          int *k;
          int i=0,j=0,t=0;
          int array[20]={67,11,64,7};
          
          k=malloc(5*sizeof(int));
          k=array;
          for(i=0;i&lt;4;i++){
              printf(&quot;%d\n&quot;,k[i]);
          }
          
          k=realloc(k,50*sizeof(int));
          
          k[4]=23;
          k[5]=81;
          k[6]=88;
          k[7]=35;
          k[8]=12;
          k[9]=5;
          k[10]=7;
          for(j=0;k[j]!='\0';j++){
          
          printf(&quot;%d\n&quot;,k[j]);
          }
          
          k=realloc(k,(j+1)*sizeof(int));
          
          for(t=0;k[t]!='\0';t++){
              
              printf(&quot;%d\n&quot;,k[t]);
          }
          
          printf(&quot;the size of the memory=%d \n&quot;,j*4);
          printf(&quot;the size of the memory=%d \n&quot;,t*4);
      
          return 0;
      }
  </code></pre>