C Exercise Example 92
100 cases of classic C language
Title: Time Functions Example 2
Program Analysis: None.
Source Code:
// Created by www.w3big.com on 15/11/9. // Copyright © 2015年 本教程. All rights reserved. // #include <stdio.h> #include <time.h> int main() { time_t start,end; int i; start=time(NULL); for(i=0;i<300000;i++) { printf("\n"); // 返回两个time_t型变量之间的时间间隔 } end=time(NULL); // 输出执行时间 printf("时间间隔为 %6.3f\n",difftime(end,start)); }
Run the above example output is:
时间间隔为 1.000