How to display real time in c++

前端 未结 6 924
梦如初夏
梦如初夏 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:37

    Some basic C++ will come in a long way: www.cplusplus.com

    int main ()
    {
        time_t rawtime; //creates and object of the built in time function
        struct tm * timeinfo; //no idea what this do
    
        while (true)
        {
            time( &rawtime ); //gets the time from the computer
            timeinfo = localtime( &rawtime ); //store that time here
    
            //it displays current date and time except time is frozen and not real time
            cout<< "Current local time and date: "<

提交回复
热议问题