Ubunut: 保存时间戳

本文介绍了在Ubuntu操作系统中如何有效地保存和处理时间戳,包括可能涉及到的命令行工具和编程接口,帮助用户在系统中管理和使用时间戳数据。
摘要由CSDN通过智能技术生成

时间戳程序:

 

/********************************************************************************
 ** ubuntu 获取时间戳 **                                                           **
 ********************************************************************************/

#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <iostream>

using namespace std;


int main()
{

    struct timeval tv;
    gettimeofday(&tv, NULL);
    printf("second: %ld \n", tv.tv_sec); //秒
    printf("millisecond:%ld \n", tv.tv_sec*1000 + tv.tv_usec/1000); //ms
    printf("millisecond:%ld \n", tv.tv_sec*1000000 + tv.tv_usec); //us
    printf("microsecond:%ld \n", tv.tv_sec*1000000000 + tv.tv_usec*1000); //ns

    long int t = tv.tv_sec*1000000000 + tv.tv_usec*1000;
    std::cout << t << std::endl;

    //char字符串赋值
    char filename1[200], filename2[200];
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值