I have a general file which constructs certain shapes and I would like to read in the lines:
0 0 1
0 x(r) y(r)
where x
and y
are functions of r
, which is a variable taken in as an argument to main, such as 2*r-4
.
Then I need to read the columns downwards into arrays.
For columns with just numbers you can do something like:
file >> x[j];
However I am unsure how to get the expressions to be read into the program and then be evaluated and then be put into an array as a number.
I am having problems reading in columns with entries of different types. Ideally I would like each to be assigned like:
temp[0]=1;
temp[1]=2*r-4;
but I am not sure how to do this.
(I am not sure whether the function fscanf
would work?)