I have a text file with 2 columns and many rows. each column is separated by spaces. i need to read them to a 2D array for further calculations. my data file looks like
0.5 0.479425539
1   0.841470985
1.5 0.997494987
2   0.909297427
2.5 0.598472144
3   0.141120008
3.5 -0.350783228
4   -0.756802495
4.5 -0.977530118
5   -0.958924275  
And my feeble attempt is
#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
#include <ctype.h>
using namespace std;
int main () {
  char line,element;
  std::ifstream myfile ("C:\\Users\\g\\Desktop\\test.txt");
  if (myfile.is_open())
  {
    while ( myfile.good() )
    {
      getline(myfile,line);
       cout << line<<endl;               
      _getch();
    }
    myfile.close();
  }
  else cout << "Unable to open file"; 
  return 0;
}
The problem is I'm not able to read them correctly.... its either reading the whole line... if I specify the delimiter as 'space' then, its not reading the next row.
Pls point out whats wrong. and what should i do to store the data into 2d array for further calculations. Thank you
 
     
     
     
    