but how would i go about doing that..it seems like a contradiction:S...my malloc looks like this

Code:

FILE *output;
float m, k, g, *x, *v, time_increment,*time, w2, w, p, *f, A, omega;
int i,CASE_FLAG;
int ivalue(int i);
time=(float *)malloc(sizeof(float)*(i+2));
x=(float *)malloc(sizeof(float)*(i+2));
v=(float *)malloc(sizeof(float)*(i+2));
f=(float *)malloc(sizeof(float)*(i+2));

but 'i' can only be determined once the second bit of my programme has been run which is after the malloc:

Code:

i++;
time[i] = i*time_increment;
v[i+1] = v[i] - (g*v[i] + w2*x[i])*time_increment + (1/m)*f[i]*time_increment;
x[i+1] = x[i] + v[i+1]*time_increment;
fprintf(output, "%f %f\n", time[i], x[i]);
}
fclose(output);
free(time);
free(x);
free(v);
free(f);
return(0);
}

also, is that the right place to put the free function..right at end of my programe?