×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: C
Posted by: Damian Pytkowski
Added: May 21, 2016 9:53 AM
Views: 11
  1. void main(int argc,char *argv[])
  2. {
  3.    char *destination;
  4.    int i;
  5.    float *p;
  6.    p=(float*)malloc(sizeof(float));
  7.    for(i=0;i<10;i++){
  8.         p[i]=10.0/(i+1);
  9.         p=(float*)realloc(p,sizeof(float)*(i+2));
  10.  
  11.    }
  12.    for(i=0;i<10;i++){
  13.         printf("%f\n",p[i]);
  14.    }
  15.    free(p);
  16. }