Using only ANSI C, is there any way to measure time with milliseconds precision or more? I was browsing time.h but I only found second precision functions.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no ANSI C function that provides better than 1 second time resolution but the POSIX function
gettimeofdayprovides microsecond resolution. The clock function only measures the amount of time that a process has spent executing and is not accurate on many systems.You can use this function like this:
This returns
Time elapsed: 1.000870on my machine.