linux c获取当前时间戳
#include #include long long getTime() { struct timeval time1; gettimeofday(&time1,NULL); long long startTime = (long long)time1.tv_sec*1000 + (long long )time1.tv_usec / 1000; return startTime;}int main(){ /* struct timeval time0; gettimeofday(&time0,NULL); long long startTime = (long long)time0.tv_sec*1000 + (long long )time1.tv_usec / 1000; struct timeval time2; gettimeofday(&time2,NULL); long long endTime = (long long)time2.tv_sec*1000 + (long long )time2.tv_usec / 1000;*/ long long time1 = getTime(); while(1) { if(getTime() - time1 > 10*1000) { printf("--------10s--------\n"); return 0; } }}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~