Enable the checkbox to check/uncheck again

I have an application with a checkbox. I want it to retain the state of the checkbox between runs (exits the application and comes back again). If the user had checked the checkbox the last time he used it, when he opens the application again, it needs to be checked.

For this I'm storing a value of 1 or 0 in a text file. When he opens up the application again, my program reads the text file and does the following:

1
2
3
4
5
6
7
8
9
10
while(CheckBoxFile.good()){
     std::getline(CheckBoxFile, line);
     ch[0] = line;
     if(ch[0] == "1"){
	myCheck.Check();
     }
     if(ch[0] == "0"){
	myCheck.UnCheck();
     }
}


How do I enable the check box again so that even though the last time he checked it, it will come up as checked but he can uncheck it again. Currently, it just remains checked, I have to run my application and only then it is enabled.
Topic archived. No new replies allowed.