Hi all
I'm trying to generate some text files and have the name of each file created increment or be random (doesn't matter which), but am having difficult as the way I know of creating txt files is by placing the name of the file between double quotes. I have tried replacing the name part with rand(), and also by placing a variable where the name appears and then incrementing the value of the variable on each iteration of the loop (variablename++).
Both failed.
Here is my code, pretty standard:
So I just wondering how I should go about this.Code:#include <iostream> #include <fstream> #include <cstdlib> using namespace std; void main() { for(int a =0;a<99;a++) { ofstream out("WantToIncrementThis"); if(!out) { cout << "cannot open file"; } out << rand() << rand() << rand()<< rand() << rand() << rand()<< rand() << rand() << rand(); out.close(); } system ("pause"); }
Many thanks for any help1!
Swerve



LinkBack URL
About LinkBacks



