在c语言里想要获得程序运行的开始时间和结束时间,怎么写?
我用time_trawtime;structtm*timeinfo;time(&rawtime);timeinfo=localtime(&rawtime);printf(...
我用
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf("程序运行开始,Currentlocal time and date: %s\n", asctime(timeinfo));
……
printf("程序运行结束,Currentlocal time and date: %s", asctime(timeinfo));
为什么得到的程序开始运行时刻与结束运行时刻是相同的? 展开
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf("程序运行开始,Currentlocal time and date: %s\n", asctime(timeinfo));
……
printf("程序运行结束,Currentlocal time and date: %s", asctime(timeinfo));
为什么得到的程序开始运行时刻与结束运行时刻是相同的? 展开
1个回答
展开全部
这样干,你少写了两行
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf("程序运行开始,Currentlocal time and date: %s\n", asctime(timeinfo));
……
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf("程序运行结束,Currentlocal time and date: %s", asctime(timeinfo));
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf("程序运行开始,Currentlocal time and date: %s\n", asctime(timeinfo));
……
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf("程序运行结束,Currentlocal time and date: %s", asctime(timeinfo));
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询