相关文章推荐
老实的火腿肠  ·  jdk8 ...·  1 年前    · 
害羞的匕首  ·  sql server 2008 - ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams how to use gettimeofday() or something equivalent with Visual Studio C++ 2008? (4 answers)
Closed 2 years ago .

I am using MSVS 2006 and trying to find time in microseconds in my program. I try to call sys/time.h in the header but this error is compiled.

fatal error C1083: Cannot open include file: 'sys/time.h': No such file or directory
Error executing cl.exe.

and this is my code,

#include<sys/time.h>
#include<stdio.h>
int main()
   struc timeval stop,start;
   gettimeofday(&start,NULL);
   /*my function here*/
   gettimeofday(&stop,NULL);
   printf("took %lu usec\n",stop.tv_usec-start.tv_usec);
                Unfortunately, there is no sys\time.h header file in MSVC. Instead, try one of the following links for some help coding this on Windows. stackoverflow 1676036 stackoverflow 2494356
– lordjeb
                Sep 2, 2014 at 22:48
                <sys/time.h> is a POSIX header, not part of the C/C++ standard library. If you are using C++ the standard header is <ctime>
– Udith Indrakantha
                Jun 25, 2021 at 7:32