how do i time my program?
i googled the topic but all teh results were ANSI C and they didnt work.
On a side note where do you get information on C, i can only find C++ and C#. MSDN doesnt even have C anymore.
how do i time my program?
i googled the topic but all teh results were ANSI C and they didnt work.
On a side note where do you get information on C, i can only find C++ and C#. MSDN doesnt even have C anymore.
What do you mean time your program? Like make it close after a certain amount of time?
You will probably have to use the time.h header, then compare the current time with the time limit in a loop and close the program if the limit is exceeded.
I expect you mean time it for example to do performance comparisons, in which case this model will work:
It's reasonably portable and should work for anything that takes more than a few hundreds of a second - for really short times you'll need something more accurate.Code:#include <clock.h> int main(void) { clock_t t1, t2; t1 = clock(); .... // do something that takes some time .... t2 = clock(); printf("Time taken: %.2f\n", (double)(t1 - t2) / CLOCKS_PER_SEC); }
--
Mats