A program relative invocation of the system time.
Compatibility:This function is compatible with the following targets:
|
EMB/RTOS
|
|
#include <time.h>
clock_t clock(void);Parameters: Remarks:
WARNING!
clock_t, defined in time.h, has a finite size that varies depending upon the target system.
#include <time.h>
#include <stdio.h>
int main()
{
clock_t start, end;
double secs = 0;
int stop = 0;
fprintf( stderr, "Press enter to start");
getchar();
start = clock();
while(stop != 'x')
{
fprintf( stderr, "Press enter to end");
getchar();
end = clock();
secs = (double)(end - start) /CLOCKS_PER_SEC;
fprintf( stderr, "Elapsed seconds = %f \n", secs);
fprintf( stderr,"Press enter to start again ");
fprintf(stderr, "or enter x to end: "); stop = getchar();
start = clock();
}
printf("\n** Program has terminated ** \n");
return 0;
}
Output:
Press enter to start <enter>
Press enter to end <enter>
Elapsed seconds = 1.200000
Press enter to start again or enter x to end: <enter>
Press enter to end <enter>
Elapsed seconds = 1.033333
Press enter to start again or enter x to end: <x enter>
** Program has terminated **
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 16, 2000