Hi everyone

well I have a new problem that makes me go crazy.

let me explain this code

enter n, steps x1

example:

n=6 ; x1=1.25 ---->1.25 2.5 3.75 5 6.25 7.5

calculate yi= xi^2 + 3xi +3

and fprintf to test.dat.

Then use the data to draw with gnuplot on screen, but thats another story.

result endless loop, huge growing .dat file 14MegCode:#include<stdio.h> #include<stdlib.h> int main (void) { double *y, *x, xi, x1; int i,n; FILE *fp; printf(" n-->"); scanf("%f",&n); printf("x1-->"); scanf("%f", &x1); y= malloc( n*sizeof(double) ); x= malloc( n*sizeof(double) ); fp=fopen("test.dat", "w"); xi=x1; for (i=0; i<n; i++) { y[i]= xi*xi - 3*xi +3; x[i]= xi; xi= xi+x1; fprintf(fp,"%f %f\n",y[i], x[i]); fflush(fp); } fclose(fp); free(y); free(x); return 0; }

and this

-1.#QNAN0 -1.#QNAN0

-1.#QNAN0 -1.#QNAN0

-1.#QNAN0 -1.#QNAN0

-1.#QNAN0 -1.#QNAN0

-1.#QNAN0 -1.#QNAN0

-1.#QNAN0 -1.#QNAN0

-1.#QNAN0 -1.#QNAN0

-1.#QNAN0 -1.#QNAN0

.

.