C 練習(xí)實例92

C 語言經(jīng)典100例 C 語言經(jīng)典100例

題目:時間函數(shù)舉例2

程序分析:無。

程序源代碼:

//  Created by www.o2fo.com on 15/11/9.
//  Copyright © 2015年 W3Cschool教程. 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);
    
    // 輸出執(zhí)行時間
    printf("時間間隔為 %6.3f\n",difftime(end,start));
}

以上實例運(yùn)行輸出結(jié)果為:

時間間隔為  1.000

C 語言經(jīng)典100例 C 語言經(jīng)典100例