I have a rather simple C++-problem, but coming from a C-background I am not really aware of all the I/O capabilities of C++. So here is the problem:
I have a simple .txt file with a specific format, the textfile looks like this:
123 points are stored in this file
pointer number | x-coordinate | y-coordinate
0 1.123 3.456
1 2.345 4.566
.....
I want to read out the coordinates. How can I do this?
The first step is fine with:
int lines;
ifstream file("input.txt");
file >> lines;
This stores the first number in the file (i.e. the 123 in the example) in lines. Now I’d like to iterate over the file and only read the x and y coordinates. How can I do this efficently?
I’d probably do it just about like I would in C, just using iostreams: