Reading file into array C++
问题 I am trying to simply read a file "input.txt" into an array people[]. The txt file has 3 numbers: 10 20 30 I am getting -9.25596e+61 instead of 10 for people[0]. Here is my code: #include <iostream> #include <string> #include <fstream> using namespace std; class Trip { private: double people[3]; public: void readFile(string file); }; void Trip::readFile(string file) { ifstream input; input.open(file); input >> people[0] >> people[1] >> people[2]; cout << people[0]; input.close(); } int main()