Hi all,
I want to read a file.
The file is like that :
20 20 1 5 6
20 21 1 2 3
21 22 2 4 6
20 20 2 3 5
20 21 6 5 2
21 22 1 6 7
....
and I would like every time that I find number1 && number2 in a line to add number3
for example to print
20 20 1+2
20 21 1+6
21 22 2+1
Could you help me please do this ?
I know how to read file but I have not idea how can I do this ?
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
float width,height,var1;
ifstream inFile;
inFile.open("data.txt");
if (!inFile)
{
cout << "Unable to open file";
exit(1);
}
while(inFile)
{
inFile >> width >> height >> var1;
cout << width << " " << height << " " << var1 << endl;
}
inFile.close();
system("pause");
return 0;
}