美文网首页
C语言:获取精度为纳秒的时间戳

C语言:获取精度为纳秒的时间戳

作者: 白祤星 | 来源:发表于2019-10-27 13:35 被阅读0次

    代码实例:


    #include <stdio.h>
    #include <sys/time.h>
    
    void main()
    {
        struct timespec timestamp;
        clock_gettime(CLOCK_REALTIME, &timestamp);
        printf("当前时间: %d 秒,%d 纳秒", timestamp.tv_sec, timestamp.tv_nsec);
    }
    

    相关文章

      网友评论

          本文标题:C语言:获取精度为纳秒的时间戳

          本文链接:https://www.haomeiwen.com/subject/xjwpvctx.html