一个c++文件有关问题

一个c++文件问题
include<fstream>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
int main()
{
    int a,b;
    while(fin>>a>>b)  fout << a+b <<"\n";
    return 0;
}

这个东西怎么用的,我写文件里两个数,没运行成功
求指教

------解决方案--------------------
#include <iostream>
#include <fstream>
using namespace std;

int main()
{    
ofstream fout;
fout.open("data.txt");
fout<<"123 456";
fout.close();

ifstream fin;
fin.open("data.txt");
int a,b;
fin>>a>>b;
fin.close();
cout<<a<<"+"<<b<<"="<<a+b<<endl;
}


输出:
123+456=579
请按任意键继续. . .