0

How would you read a text file containing the following columns:

x1 y1 x2 y2
1 6 -1 -1
3 6 -2 -4

This is what I have so far...

const string IN_FILENAME = "input.txt";
const string OUT_FILENAME = "inputoutput.txt";

double x1;
double y1;
double x2;
double y2;

string label,
inFile.open(IN_FILENAME.c_str());
outFile.open(OUT_FILENAME.c_str());
inFile >> label;
  • You may find option two of the first answer to [Read file line by line using ifstream in C++](https://stackoverflow.com/questions/7868936/read-file-line-by-line-using-ifstream-in-c) helpful. – user4581301 Apr 16 '20 at 03:57
  • Consider saving yourself a couple variables: `inFile.open("input.txt");` – user4581301 Apr 16 '20 at 03:58
  • Does this answer your question? [Read file line by line using ifstream in C++](https://stackoverflow.com/questions/7868936/read-file-line-by-line-using-ifstream-in-c) – Azeem Apr 16 '20 at 06:14

0 Answers0