源程序:
#include <iostream>
using namespace std;
int main()
{
int x, y;
cin >> x >> y;
freopen("c:\test.txt", "w", stdout);
if (y == 0)
cerr<<"error."<<endl;
else
cout << x << "/" << y << "=" << x / y << endl;
system("pause");
return 0;
}
运行结果:
输入:9 3
在c盘上产生文本文件test.txt,内容为:9/3=3