3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
純C/C++ mktime()函數 資料來源: http://www.w3big.com/zh-TW/cplusplus/c-function-mktime.html 線上編譯器: https://www.tutorialspoint.com/compile_c_online.php time_t mktime(struct tm *timeptr)函數,把timeptr所指向的結構轉換為一個依據本地時區的time_t值 code: #include #include #define BST (+1) #define CCT (+8) int main () { time_t rawtime; struct tm *info; int ret; char buffer[80]; time(&rawtime); /* 获取 GMT 时间 */ info = gmtime(&rawtime ); ret = mktime(info); if( ret == -1 ) { printf("错误:不能使用 mktime 转换时间。\n"); } else { strftime(buffer, sizeof(buffer), "%c", info ); printf(buffer); } printf("当前的世界时钟:\n"); printf("伦敦:-:d\n", (info->tm_hour+BST)$, info->tm_min); printf("中国:-:d\n", (info->tm_hour+CCT)$, info->tm_min); return(0); }

本文由jashliaoeuwordpress提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦