Thread: First Run Only
View Single Post
Old 02-03-2007, 03:19 PM   #3 (permalink)
Spunky_Man
Newbie
 
Join Date: Jan 2006
Posts: 34
Default

Quote:
Originally Posted by mordero View Post
b)write a small file in the same directory as the application.
That's what I've been trying to do... Here's what I've been trying to do (keep in mind that these are cuts from the program, not the entire program):

Code:
// Cut 1: Prototypes...
int Config (int check, int firstrun);
int Config2 (string line, int firstrun);

// Cut 2: main()...
int main()
{
    int check;
    int firstrun;
    
    Config(check,firstrun);
    
    if (check == 1 && firstrun == 1)
    {
              ofstream config;
              config.open ("firstruncheck.sece", ios::out);
              config << "false";
              config.close();
              
              ofstream autoexec;
              autoexec.open ("autoexec.cfg", ios::out | ios::app);
              autoexec << "// SECE execution commands...\n";
              autoexec.close();
    }
    else
    {
        cout << "The program seems to have returned an error...\n";
    }
// Cut 3: Functions...
int Config (int check, int firstrun)
{
     string line;
     ifstream config ("firstruncheck.sece");
     if (config.is_open())
     {
                          while (!config.eof())
                          {
                                getline (config,line);
                                Config2(line,firstrun);
                                continue;
                          }
                          check = 1;
                          return (check,firstrun);
     }
     else
     {
         cout << "The program has returned an error...\n";
         cout << "Please try again...\n";
         main();
     }
}
// Function 2...
int Config2 (string line, int firstrun)
{
    if (line == "true")
    {
             firstrun = 1;
    }
    return (firstrun);
}
There ya have it. That is all of the relevant information. Can you correct it?
Spunky_Man is offline   Reply With Quote