[英]tm struct object confusion
如果可以的話,我對如何使用tm struct對象感到困惑。
printf("The current date is %d-%d-%d\n", now.tm_mon, now.tm_mday, now.tm_year);
我的輸出是;
The current date is 11-31-112
但是當我這樣做時;
printf("The current date is %d-%d-%d\n", now.tm_mon + 1, now.tm_mday, now.tm_year
+ 1900);
我的輸出是;
The current date is 12-31-2012
我有些困惑,如何將+1和+1900的加法正確格式化輸出時間? 預先感謝您的任何幫助!
從聯機幫助頁:
tm_mon自一月以來的月數,范圍為0到11。
tm_year The number of years since 1900.
您可能還想看看用於輸出的strftime
函數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.