srandom and random
-
Sorry to get more and more questions here, but with your support I am solving issues one by one :) I got 2 errors:
error C3861: 'srandom': identifier not found
error C3861: 'random': identifier not foundthe problem is I don't know how to replace them with Windows versions ... because I didn't found them as defined somewhere ... from your experience, what could be similar windows functions ?
-
Sorry to get more and more questions here, but with your support I am solving issues one by one :) I got 2 errors:
error C3861: 'srandom': identifier not found
error C3861: 'random': identifier not foundthe problem is I don't know how to replace them with Windows versions ... because I didn't found them as defined somewhere ... from your experience, what could be similar windows functions ?
Maybe you can have a look at <random> header[^] and/or srand (<cstdlib> header)[^]?
"Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."
-
Sorry to get more and more questions here, but with your support I am solving issues one by one :) I got 2 errors:
error C3861: 'srandom': identifier not found
error C3861: 'random': identifier not foundthe problem is I don't know how to replace them with Windows versions ... because I didn't found them as defined somewhere ... from your experience, what could be similar windows functions ?
-
Maybe you can have a look at <random> header[^] and/or srand (<cstdlib> header)[^]?
"Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."
-
Sorry to get more and more questions here, but with your support I am solving issues one by one :) I got 2 errors:
error C3861: 'srandom': identifier not found
error C3861: 'random': identifier not foundthe problem is I don't know how to replace them with Windows versions ... because I didn't found them as defined somewhere ... from your experience, what could be similar windows functions ?
Probably need to use
srand()
andrand()
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Probably need to use
srand()
andrand()
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Works, but is it wise? Depending no what you are doing, you might want to use the [rand_s ](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rand-s?view=vs-2019) function instead. Be aware that some implementations of
rand()
have quite short periods and are predictable, so may not be a good choice if you require a good source of randomness. See also [MSC30-C. Do not use the rand() function for generating pseudorandom numbers - SEI CERT C Coding Standard - Confluence](https://wiki.sei.cmu.edu/confluence/display/c/MSC30-C.+Do+not+use+the+rand()+function+for+generating+pseudorandom+numbers) -
Works, but is it wise? Depending no what you are doing, you might want to use the [rand_s ](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rand-s?view=vs-2019) function instead. Be aware that some implementations of
rand()
have quite short periods and are predictable, so may not be a good choice if you require a good source of randomness. See also [MSC30-C. Do not use the rand() function for generating pseudorandom numbers - SEI CERT C Coding Standard - Confluence](https://wiki.sei.cmu.edu/confluence/display/c/MSC30-C.+Do+not+use+the+rand()+function+for+generating+pseudorandom+numbers) -
I have tried to use
srand_s
andrand_s
, but no one is recognized by my compiler:error C3861: 'srand_s': identifier not found
error C3861: 'rand_s': identifier not foundSee the Remark section in [rand_s | Microsoft Docs](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rand-s?view=vs-2019)