srand (time (0))中time(0)返回的秒数为什么不会越界?
来源: 互联网 发布时间:2016-12-03
本文导语: 在GNU C Library中: Data Type: time_t This is the data type used to represent simple time. Sometimes, it also represents an elapsed time. When interpreted as a calendar time value, it represents the number of seconds elapsed since 00:00:...
在GNU C Library中:
Data Type: time_t
This is the data type used to represent simple time. Sometimes, it also represents an elapsed time. When interpreted as a calendar time value, it represents the number of seconds elapsed since 00:00:00 on January 1, 1970, ...
In the GNU C library, time_t is equivalent to long intf.
Function: time_t time (time_t *result)
The time function returns the current calendar time as a value of type time_t.
Function: void srand (unsigned int seed)
To produce a different pseudo-random series each time your program is run, do srand (time (0))
time(0)返回的是个long int型数据,而 srand()需要的是 unsigned int型数据,类型不匹配?
清朋友解惑,谢谢。
Data Type: time_t
This is the data type used to represent simple time. Sometimes, it also represents an elapsed time. When interpreted as a calendar time value, it represents the number of seconds elapsed since 00:00:00 on January 1, 1970, ...
In the GNU C library, time_t is equivalent to long intf.
Function: time_t time (time_t *result)
The time function returns the current calendar time as a value of type time_t.
Function: void srand (unsigned int seed)
To produce a different pseudo-random series each time your program is run, do srand (time (0))
time(0)返回的是个long int型数据,而 srand()需要的是 unsigned int型数据,类型不匹配?
清朋友解惑,谢谢。
|
如果64位机器,我是看不到越界到那天了
如果是32位机器,我估计还能活着看到那天。
楼主试着设置时间到越界到那天以后看看,估计是2038年的某天/
如果是32位机器,我估计还能活着看到那天。
楼主试着设置时间到越界到那天以后看看,估计是2038年的某天/
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。