how to create timer in c++ application?

hello,people.. in console ,there are different things that we do,like printing the values but what should we do if we want to put the timer for changing the values.suppose in program john has 5 five values in array[]={1,2,3,4,5) and after debugging,number 1 pops up and for number 2 it should take like 30 second or so on..well,just thing is ,there we should be able to put timer between the values we print???
build your own delay function using time functions.
rough code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<time.h>
int main()
{
clock_t initialtime;
for(till end of array)
{
 print
initialtime=clock();
 mydelay(initialtime);
}
}
//delay func
void mydelay(clock_t initialtime)
{
  clock_t requireddelay;
  clock_t temp;
   requireddelay=initialtime+(CLK_TCK*30);//assumed 30 seconds
  temp=clock();
while(temp<=requireddelay)
{ temp=clock();
}
}
Topic archived. No new replies allowed.