I have an input file set up like this:
Hello there
1 4
Goodbye now
4.9 3
And I try to read the data as so:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
ifstream input("file.txt");
string name;
double num1, num2;
while(!input.eof()){
getline(input, name);
input >> num1;
input >> num2;
cout << name << endl;
cout << num1 << " " << num2 << endl;
}
}
But the read seems to be failing. Can anyone help me here?