i have a function that read config file and i wanted to reload this function to get the new variables
void readConfigFile()
{
ifstream File;
File.open("config.txt", ios::in);
while (!File.eof()){
string line;
int Hour;
int Minuts;
getline(File, line);
File >> Hour >> Minuts;
}
File.close();
}
int main()
{
readConfigFile();
while (1) {
time_t now;
struct tm *current;
now = time(0);
current = localtime(&now);
if( current->tm_hour == Hour && current->tm_min == Minuts){
std::cout << "Done" << std::endl;
}
Sleep(5000);
}
return 0;
}
how i can reload this readConfigFile() function to get the new Hour / Minuts while application running
for example
if(Clicked Button){
reload readConfigFile();
}
while i searching on internet about reload
i found that i can do that with operators overloading
but i couldnt use it
i am still begainner 🙁
Thank You 🙂
I’m guessing that the problem is that the variables
HourandMinuts(sic) are local to thereadConfigFilefunction.That means that whenever you call
readConfigFileyou only change those local variables, not whatever global variabled you might have.If those variables were global, then you just have to call
readConfigFileagain, and it will read into them again.