請問一下 你的這個問題最后是怎么解決的。我現在用vs2013第一次寫帶有時間的代碼,也碰到說localtime_s未初始化的現象 求教解決方法。
2 回答

qq_花開花謝_0
TA貢獻1835條經驗 獲得超7個贊
123456789101112131415161718192021222324252627282930 | #include <stdio.h> #include <time.h> #define TIME_MAX 32 void get_time( void ); int main() { get_time(); getchar (); return 0; } void get_time( void ) { time_t now; time (&now); // 定義兩個變量,存儲轉換結果 struct tm tmTmp; char stTmp[TIME_MAX]; // 轉換為tm結構 localtime_s(&tmTmp,&now); // 轉換為字符串并輸出 asctime_s(stTmp,&tmTmp); printf ( "Current time is: %s\n" ,stTmp); } |
- 2 回答
- 0 關注
- 1292 瀏覽
添加回答
舉報
0/150
提交
取消