Apologies if this question is stupid, I'm new to coding, especially in C++. I'm trying to read in data points from a space-separated text and then use the printf function to get it output them to the console. When I try this;
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main() {
double x[1000];
int i = 0;
int j;
double y[1000];
double sigmay[1000];
ifstream dataFile("xys_test.txt");
if (dataFile.is_open()) {
while (!dataFile.eof())
dataFile >> x[i] >> y[i] >> sigmay[i];
printf("x = %5.2f, y = %5.2f, sigmay = %5.2f\n", x[i], y[i], sigmay[i]);
i++;
}
}
All the console output gives me is the last data point, when I was hoping that all the points would be output into the console. How can I resolve this?