Hi there, I'm fairly new to C++ and have begun working with pointers. I wish to create am array called sigmaf_point that reads data from a text file. I have managed to get that working, but when it comes to using this pointer I come across some problems. The array is created as such:
I then create a coordinate system inside the main file, as the program I am writing is about modelling the movement of atoms, which requires you to know the coordinates:Code:double sigma [5]; double *sigmaf_point = sigma; void read(double *&sigmaf_point) string s; ifstream Dfile; std::stringstream out; out << 1; s = out.str() + ".TXT"; Dfile.open (s.c_str()); if (Dfile.fail()) { return; } for (int i=0; i<1; i++) { * * * * * * Dfile >> sigmaf_point[i]; } }
Now, the problem arises when I want to calculate a new variable as so:Code:int main(); double **coords_fluid = new double*[5000]; for (int i = 0; i < n_atoms_methane; i++) { coords_fluid[i] = new double[4]; }
I get the error C2064: term does not evaluate to a function taking 1 arguments, and a red line under sigmaf_point that says it must be pointer to function type. I am a bit confused about this. Any help would be great.Code:for (int i = 0; i <= n_atoms-1; i++) { sf1=sigmaf_point(coords_fluid[i][3]); }


Reply With Quote

Bookmarks