#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
using namespace std;
int main(void)
{
for(int COUNT = 0; COUNT <= 1000; COUNT++)
{
if(COUNT > 1000)
{
break;
}
if(COUNT <= 1000)
{
std::string TO_STRING;
std::stringstream OUTPUT;
OUTPUT << COUNT;
TO_STRING = OUTPUT.str();
ofstream myfile;
FILE.open ("data.txt");
FILE << TO_STRING << "^" << TO_STRING << "+" << endl;
FILE.close();
}
}
cin.get();
return 0;
}
I have a loop that runs until the specified count in reached, and in this loop, the string prints just fine to the specified text file. However, I'm a bit confused as to how I can print each string that is created each time the loop runs. The file only contains the output from the last loop run. How can I have each created string be printed onto a new line until the threshold is met?
- xtremerocker