Linux练习(获得系统时间)

#include 
#include 
#include 
int main()
{
        int i;
        time_t the_time;
        for(i=1;i<=5;i++)
        {
            the_time=time((time_t*)0);
            printf("the time is %ld\n",the_time);
            sleep(2);
        
        }
        exit(0);

}

时间是从1970年1月1日开始的。

函数原型:

#include

time_t time(time_t *tloc);

转载于:https://www.cnblogs.com/tiandsp/archive/2012/09/09/2677429.html

你可能感兴趣的:(Linux练习(获得系统时间))