您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關(guān)linux中asctime()和asctime_r()函數(shù)怎么用的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
asctime() asctime_r() 將時間和日期以字符串格式返回‘
函數(shù)原型如下:
1 #include 2 3 struct tm *gmtime(const time_t *timep); 4 struct tm *gmtime_r(const time_t *timep, struct tm *result); 5 6 char *asctime(const struct tm *tm); 7 char *asctime_r(const struct tm *tm, char *buf); 8 9 10 /**gmtime是把日期和時間轉(zhuǎn)換為格林威治(GMT)時間的函數(shù)。將參數(shù)time 所指的time_t 結(jié)構(gòu)中的信息轉(zhuǎn)換成真實(shí)世界所使用的時間日期表示方法,然后將結(jié)果由結(jié)構(gòu)tm返回**/ 11 12 /**asctime 將時間以換為字符串字符串格式返回 **/
eg:
1 #include 2 #include 3 #include 4 5 int main() 6 { 7 time_t timep; 8 time(&timep); 9 10 printf("%s\n", asctime(gmtime(&timep))); 11 12 return 0; 13 }
感謝各位的閱讀!關(guān)于“l(fā)inux中asctime()和asctime_r()函數(shù)怎么用”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。