I'm trying to get my program to read from a text file, but the only way I'm able to get it accurate at the moment is to set the first loop to the number of lines of data that I have. I'm looking for a way to set it so that I can have it read until the end of the file. Using the !(in.eof()) thing gives me an extra line at the end. Any help would be appreciated, sorry if I'm not overly clear.
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
int a,b;
ifstream in("d:\\testin.txt");
ofstream out("d:\\testout.txt");
for(int l=1; l<=14; l++)
{
b=0;
for(int c=1; c<=2; c++)
{
in>>a;
b=b+a;
}
out<<l<<" "<<b<<endl;
}
return(0);
}