且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何读取srand的值(time(null))

更新时间:2023-02-03 12:20:38

看到这个, srand - C ++参考​​a> [ ^ ]。它设置种子,然后调用rand()来获取值。


时间(null) value是 rand()调用的返回值。

有关示例,请参阅 RyanDev 提出的链接

i am new to C . I am using srand(time(null)) to 'seed' a time value. My question is how to retrieve the value seeded by this function? i want to display the value on the screen

See this, srand - C++ Reference[^]. It sets up the seed then you call rand() to get the value.


The value 'seeded' by the time(null) value is the return value of the rand() call.
See the link proposed by RyanDev for an example.