Expand|Select|Wrap|Line Numbers
- #include <cstdlib>
- #include <ctime>
- #include <iostream>
- #include <sstream>
- #include <fstream>
- using namespace std;
- void main()
- {
- srand((unsigned)time(0));
- int random_integer;
- string dir = "";
- string txt = ".txt";
- string file;
- string str = "";
- char c;
- ifstream myFile;
- do {
- string str = "";
- for(int index=0; index<1; index++)
- {
- random_integer = (rand()%25)+65;
- c = (char)random_integer;
- str += c;
- }
- file = str;
- file.insert (1,txt);
- myFile.open(file.c_str());
- if (!myFile) {
- cout << "Unable to open " << file << endl;
- }
- } while (!myFile);
- cout << "File open";
- }