I am new to programming, so I have what is probably a basic question. I currently have a text file with 2 columns. Each line has x and y numbers separated by white spaces. These are the first five lines of the file:
120 466
150 151
164 15
654 515
166 15
I want to read the data and store them into x and Y columns and then call for the data some where else in the program for eg x[i] and y[i]. Say, I do not know the number of lines. This is the part of my code where I attempt to do just that.
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
double X[];
double Y[];
ifstream inputFile("input.txt");
string line;
while (getline(inputFile, line))
{
istringstream ss(line);
double x,y;
ss >> x >> y;
X = X + [x];
Y = Y + [y];
return 0;
}
}