localized srandom?

2019-08-18 21:17发布

I'm using std::random_shuffle and srandom, and wonder if it's possible to constrain srandom()'s effect to local block of code.

To be more precise, For a server application, I need to have different random seeds for different clients and keep using this pre-determined seed for random number generation per clients.

Thank you

1条回答
2楼-- · 2019-08-18 21:52

The routines you are looking for are srandom_r(3) and random_r(3):

http://www.kernel.org/doc/man-pages/online/pages/man3/random_r.3.html

查看更多
登录 后发表回答