c語(yǔ)言localtime函數(shù) C語(yǔ)言獲取系統(tǒng)時(shí)間的幾種方式?
C語(yǔ)言獲取系統(tǒng)時(shí)間的幾種方式?1 use time time(time *timer)to seconds2 use clock clock()將CPU時(shí)間設(shè)置為1/clocks /SEC sec
C語(yǔ)言獲取系統(tǒng)時(shí)間的幾種方式?
1 use time time(time *timer)to seconds
2 use clock clock()將CPU時(shí)間設(shè)置為1/clocks /SEC seconds
3使用double difftime(time) timer1,time計(jì)算時(shí)間差。如果使用MFC的CTime類,可以使用CTime::getcurrenttime()精確到秒
6獲得高精度時(shí)間,您可以使用
bool queryPerformance frequency(Largeuinteger*lpfrequency)
獲取系統(tǒng)計(jì)數(shù)器的頻率
bool queryPerformance counter(Largeuinteger*lpperformancecount)
獲取計(jì)數(shù)器的值
然后將兩個(gè)計(jì)數(shù)器之間的差除以頻率以獲取時(shí)間。
7個(gè)多媒體計(jì)時(shí)器函數(shù)
以下函數(shù)用于多媒體計(jì)時(shí)器。
timeBeginPeriod/timeEndPeriod/timeGetDevCaps/timeGetSystemTime
#include<stdio.h>
#include<time.h>
int main()
{
timeut stamp=time(NULL)-24*60*60
struct tm*t=localtime(&stamp)
printf(“d d) dn“,1900 t->tm年,t->tm月,t->tm日)
返回0
}