Is there a way to record how many times a program is run in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there a way to record how many times a program is run in c++?

It could be used as the seed for random numbers, of course I could just use the time, but I'm just wondering.

13th Nov 2017, 12:54 PM
Nathan Comer
Nathan Comer - avatar
3 Answers
+ 5
You can have it append an external file each time it is run
13th Nov 2017, 12:57 PM
Arthur Tripp
Arthur Tripp - avatar
+ 3
as arthur has mentioned, you can use an external file to record how many times it ran.
13th Nov 2017, 3:41 PM
shobhit
shobhit - avatar
+ 2
Of course, the user might delete it at anytime. There are system dependent storage that is less likely to disappear (windows registry), but nothing is guaranteed. Some software updates a static variable in the executable file. But, a determined user can change that. Every way I know about can be broken, unless it is a feature of the os.
13th Nov 2017, 1:19 PM
John Wells
John Wells - avatar