c - How to store a changed variable as the original variable -
c - How to store a changed variable as the original variable -
say, wanted know how many times programme has been executed. possible have variable, when programme has been accessed increment variable 1 etc. , store original variable next time executed, can incremented again.
e.g. (this not right or real code)
/*variable stored*/ int num; /*initial value*/ num = 0; . /*some stuff i'll do*/ /*so num becomes incremented*/ /*please don't rage have done way*/ num = num + 1;
...and somehow store int num
.
please help me, suggestions welcome.
in question, term program little ambiguous. sake of clarity, allow me split question 2 seperate parts.
if question regarding possibility below cases,
how many times function has been executed?
yes, utilize static
variable counter.
how many times binary has been executed?
yes again, cannot achieved using without file i/o. need utilize file i/o write value file 1 time binary has been executed. each execution of binary, read value file, update , write it.
c variables
Comments
Post a Comment