Hello,
I need to read the data from a .dat file like the following one:
#Curve 0 of 1, 286 points
#x y type
13.9896 -0.0426566 i
13.9861 -0.0137144 i
13.9826 0.00222783 i
13.9792 0.0421701 i
13.9757 0.0271066 i
13.9722 0.0330488 i
and so on…
I need to jump the empty lines or the ones with “#” and put the values in X[], Y[].
I was able to open the file, count the data lines to know X and Y length then I did the following:
string line1;
i=0; double x1[dim]; double y1[dim];
while (!file1.eof())
{
getline(file1, line1);
if (line1.length() == 0 || line1[0] == ‘#’){continue;}
else{fscanf(file1, “%lf %lf\n”, &x1[i], &y1[i]);}
}
cout << x1 << ’ ’ << y1 << endl;
but the compiler says:
my_prog.C: In function ‘int main(int, char**)’:
my_prog.C:65: error: invalid conversion from ‘void*’ to ‘FILE*’
my_prog.C:65: error: initializing argument 1 of ‘int fscanf(FILE*, const char*, …)’
How can I do?
Besides, I am just compiling with: c++ my_prog.C -o my_prog.exe
Is there a better way?
Thank you very much!
Elena