> while (getline(indata, line, '\n'));
First, note the semicolon at the end. That's the body of the loop.
Second, ¿what do you expect line 23 to do? You've already exhausted the file in line 17
I'll give you a hint: you never needed to modify the code I gave you.
I'll give you an explanation: it reads the input file line by line, and each time it reads a line it extracts each number from the line as x (so x becomes a, b, c, d, e, ..., although in your case just a and b).
I'll give you another hint: you don't need to read anything outside the while() loop.
indata >> num1 >>num2;
while (getline(indata, line, '\n'))
{
stringstream num1, num2(line); '\n';
while (num1,num2>>x)
num3 += x;
outfile << "The number added is:" << num3 << '\n';
so like this? Because my output doesn't add up like it should.
My first value is coming up 0(zero), my second is the addition of the first line with the first digit of the second line, and I can't seem to find where I'm having my problem at. Any help would be greatly appreciated.
Look at line 4 very clearly...I have no idea what that is supposed to do.
Basically what you want to do is create a stringstream from the line you read in then stream each set of numbers and add them.
Catfish already showed you how to use it but here it is again:
1 2 3 4 5 6 7 8
while( getline( input , line ) ) //loop while it reads in lines
{
stringstream numbers( line ); //add the line to a stream
int x , sum = 0; //sum is the sum of each line
while( numbers >> x ) //convert each line into integers
sum += x; //add the values to the sum
out << sum << '\n'; //output the sum of each line
}