时间戳程序:
/********************************************************************************
** 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];