I have an input file in text format that looks like:
G: 5 10 20 30
C: 24 49 4.0 30.0
I'd like to set each of these to an array, array, respectively. I saw from this answer reading input parameters from a text file with C, a way to read some of the values, but how would I get the arrays G and C?
EDIT:
If I removed G:, and C: from the .txt file I could just run a for loop.
double *conc = (double*)malloc(properConfigs*sizeof(double));
double *G = (double*)malloc(properConfigs*sizeof(double));
for (int i=0;i<properConfigs;i++)
fscanf(inputfile,"%lf", &G[i]);
for (int i=0;i<properConfigs;i++)
fscanf(inputfile,"%lf", &conc[i]);
This would work, but I'd like to be able to account for someone saving the .txt file in a different order or at some point adding more rows (with different parameters).