Hello All,
I would like to read equations from a datafile and use them in my main program.
For example, my data file might look like:
sin(i%360) + 2*sin(j%360)
2*cos(i%360) - sin(j%360)
and so on.
So each line will be a separate equation.
Variable i and j will be defined and values set in the main application.
I can read the lines using something like this:
Code:
FILE *file_ptr;
char record[MAX_REC_SIZE + 1];
file_ptr = fopen("EQS.DAT","r");
while(fgets(record,MAX_REC_SIZE+1,file_ptr) != NULL)
fputs(record,stdout);
fclose(file_ptr);
and see the equation written to the screen.
I am stuck though on how to assign this to a variable within my program so that I can put it to use.
For example, say i have a variable called eq1 of type float.
How do I assign the value of record (above, a line from the data file) to this float.
Thanks for any advice,
p