PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Implementing a stopwatch.

I would like the time total time taken to be displayed after my program completes:

Code:

#include <stdio.h>
#include <stdlib.h>

main ()
{

long ctr = 1;


for(ctr = 1; ctr <=999999; ctr++)
{
printf("Still counting...");
printf("%d \n", ctr);
}


system("PAUSE");
return 0;
}


I have looked all over the net and attempted to try some things, but nothing has seemed to work. Any ideas?
Dave Johnston · 12 Jul 2003, 17:37 UTC
Try getting the time when the program starts (a), the time when the program ends (b), then subtract a from b to get the time difference.

You can get the current time as a DWORD using ::GetTickCount() on the PPC, or ::tickGetTime (I think) on the PC.
Either that, or time().