とりあえず
822の1行目を
#include <iostream.h>
↓
#include <fstream.h>

に直し、
void main()
{
の次の行に
ofstream cout( "素数−実行結果.txt" );

を挿入するだけで君の期待する物は得られる