获取程序运行时间

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

#include<stdio.h>
#include<Windows.h>
#include<process.h>

void ()
{
extern int x; //外部声明
printf("%dn", x);

}
int x = 10;

//实时打印程序运行时间打印到标题上
void time(void *p)
{
int i = 0;
while (1)
{
char str[100] = { 0 };
sprintf(str, "title 当前第%d秒", i);
system(str);
i++;
Sleep(1000);

}
}
void time2()
{
time_t start, end;
time(&start);//获取当前时间,放在start变量中
Sleep(4000);
time(&end);
printf("%d", (unsigned)(end - start));//获取时间差
getchar();
}
void h()
{
printf("%d", 1);
}
void main()
{
//Extern();
_beginthread(time, 0, NULL);
getchar();
}