本文介绍了在打印时,为什么要注意如下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
printf("D A T E :%d/%d/%d \ n" ,,(* t_tm_begin).tm_mon + 1,
(* t_tm_begin).tm_mday,(* t_tm_begin).tm_year + 1900);
printf("D A T E<MN/DD/YY>: %d/%d/%d\n",(*t_tm_begin).tm_mon+1,
(*t_tm_begin).tm_mday,(*t_tm_begin).tm_year+1900);
为什么要+1和+1990?
why+1and+1990?
推荐答案
+1,因为tm_mon的范围是[0,11],并且在打印时,您希望看到[1,12].
+1 because tm_mon's range is [0,11] and for printing, you want to see [1,12].
+1900,因为tm_year是相对于1900年存储的.
+1900 because tm_year is stored relative to to the year 1900.
您会注意到tm_mday不需要更正,因为它的范围是[1,31].
You'll notice tm_mday doesn't require correction, this is because it's range is [1,31].
这篇关于在打印时,为什么要注意如下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!