<edit>Come to think of it, is Program Files special?</edit>
Here's the code:
#include <iostream>
#include <fstream>
using namespace std;
bool nextChar(char ¶m);
int main(void)
{
ifstream inFile;
bool hasRunBefore;
inFile.open("C:\\Program Files\\ID tracker\\has run.txt");
if(inFile)
{
cout << "Running this program can cause data-loss. If you have stored \
any data already, please save it before continuing.\nPress \
enter to continue . . ." << endl;
cin.sync();
cin.get();
}
else
{
ofstream outFile;
outFile.open("C:\\Program Files\\ID tracker\\has run.txt");
outFile << "Do not delete this file.\n\
Feel free to modify it though.\n\
Just make sure this file exists.";
outFile.close();
}
char char1, char2;
char1 = char2 = 96;
ofstream outFile;
string pathName;
while(nextChar(char1))
{
while(nextChar(char2))
{
pathName = (string) "C:\\Program Files\\ID tracker\\Database\\" + char1 + "\\" + char2 + ".txt";
outFile.open(pathName.c_str());
// Words with a sharp cannot be a result. Therefore, comment lines should include sharps.
outFile << "#Words_beginning_with:_" << char1 << char2 << "..." << endl;
cout << "Created " << pathName << endl;
outFile.close();
}
}
cout << "The database has been constructed.\n"
<< "Press enter to exit . . ." << endl;
cin.sync();
cin.get();
return 0;
}
bool nextChar(char ¶m)
{
// If the char is 'Z' then break outta main's loop.
// Else increment it and return true to remain in the loop.
if(param == 122)
param = 48;
else if(param == 57)
{
param = 96;
return false;
}
++param;
return true;
}
Thanks for reading this topic.
This post has been edited by hulla: 23 November 2011 - 01:07 PM

New Topic/Question
Reply




MultiQuote






|