ok, just to let you all know, this is basically my first complete program, so if what i'm asking is just plain stupid, don't yell.
the program is designed to make a backup of a text file every two hours until manually terminated. the problem i have is that i don't know a good way to make a timer to do that. i tried one way, and yes it runs fine, but it ended up taking about 70% of my cpu resources to run a 90-line program. so obviously that's no good. here's the way i tried to make the timer.
if anybody knows a good way to do this(and i'm sure everybody but me does), please let me know. any help is greatly appreciated.Code:int main() { int x=0; int diff=0; long start=0, current=0; char file_name[15]=""; while(x==0) { start=time(NULL); while(diff<60) { current=time(NULL); diff=current-start; } strcat(file_name,get_name()); create_backup(file_name); } return 0; }



LinkBack URL
About LinkBacks


