I have double numbers in a file (one on each line) that I am trying to read into a c++ array. I am using the below code, but get the below error while running:
segmentation fault: 11
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main () {
    string line;
    ifstream myfile ("temp2.csv");
    std::vector<double> myArray;
    int index = 0;
    if (myfile.is_open())
    {
        while (! myfile.eof() )
        {
            getline (myfile,line);
            cout << line << endl;
//            myArray[index++] << line;
            myArray[index++] = atoi( line.c_str() );
        }
        myfile.close();
    }
    else cout << "Unable to open file";
    return 0;
}
 
     
     
     
    