I am new to C programming, I wrote code and want to get it's runtime. Here is what I did it. Every time I run my code, I get a different run time value. Is it right? or is something wrong with my code?
int main(int argc, char *argv[])
{
time_t start,end;
start=clock();
// this part is some operation
end=clock();
int running_time=end-start;
printf("Time taken: %d",running_time);
return 0;
}
Nothing wrong with code. Its just understanding of OS scheduler for your program execution, It varies all time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With