Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Exercise 92

C Exercise 92

100 Classic C Language Examples 100 Classic C Language Examples

**Problem:** Time function example 2

**Analysis:** None.

Program source code:



//  Created by www.runoob.com on 15/11/9.

//  Copyright © 2015 Runoob Tutorial. All rights reserved.

//



#include 

#include 



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));

}

The above example produces the following output:



时间间隔为  1.000

100 Classic C Language Examples 100 Classic C Language Examples