How to display real time in c++

前端 未结 6 982
梦如初夏
梦如初夏 2021-01-24 14:04

Can some one tell me how do i display real time in c++. what i mean is that while the program is running you can see the seconds and or minutes counting down like a real clock h

6条回答
  •  野性不改
    2021-01-24 14:45

    The standard C++ language did not have any notion of time till the latest C++11 standard published in 2011, and rarely implemented. On Linux, you could consider using GCC 4.6 or 4.7 which implements most of it.

    (older C++03 gives you )

    Otherwise, time is given by operating system specific libraries and system calls (such as gettimeofday and clock_gettime on Linux and Posix)

    If you have a fully C++11 conformant implementation of the latest C++ standard (which may be unlikely, in particular on Windows), you could use the standard header.

提交回复
热议问题