[Dev-C++] Does the result of my called clock() is wrong?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <per...@ya...> - 2004-07-09 12:22:44
|
The below program is just my simple test for clock( ).I use a nesting "for" sentence to consume time.But it seem that the clock( ) doesn't work.The t1 and t2 are all zero.Why the result is in this way?Perhaps my comprehension in clock( ) is wrong.Can anyone give an example about using clock( )?
/* ********************************* */
#include <stdio.h>
#include <time.h>
main()
{
/*
time_t biggest = 0x7FFFFFFF;
printf("biggest = %s \n", ctime(&biggest));
system("PAUSE");
*/
int i, j;
clock_t t1, t2;
t1 = clock() / CLOCKS_PER_SEC;
printf("t1 = %d\n", t1);
for (i = 0; i < 9999; i++)
for (j = 0; j < 9999; j++)
;
t2 = clock() / CLOCKS_PER_SEC;
printf("t2 = %d\n", t2);
system("PAUSE");
}
/* *************************** */
The result is :
t1 = 0
t2 = 0
---------------------------------
Do You Yahoo!?
100兆邮箱够不够用?雅虎电邮自助扩容! |