i have a file called "test_data_4" which contains a single column of 20001 numerical values "1.09964047e+001 1.10765811e+001 1.11526284e+001 1.12244983e+001 1.12921441e+001 1.13555205e+001 1.14145834e+001 1.14692903e+001 1.15196004e+001 ...." and so on I am writting a program that reads the file and have got stuck. Code: #include <vector> #include <cstdlib> using namespace std; int main() { ifstream infile("test_data_4.dat"); cout << "reading from file"<<endl; cout<<"how many points shall we consider "; int N=0;cin>>N; //the numbers of data points we shall take from the file vector<long> data(N); //the vector we assemble from the file cout<<"reading from the file "<<endl; long n=2;int j=0; while(j<N) { infile >> n;cout<<n<<endl; data[j]=n; j++; } // Note that n is overwritten every time we loop infile.close(); cout << "The file comtains the list of values:"<<endl; for(int i=0; i<(int) data.size(); i++) {cout << data[i] << endl;} return 0; } It currently seems to think that all the above are simply repetitions of the number 1.
Hmmnn i've tried importing various different versions of test_data_4 and it seems to import all the data up to the full stop