Top "Srand" questions

a function which initializes the pseudo-random number generator in C/C++ or PHP

How to use function srand() with time.h?

My program contains code that should generate a random positive integer number every time I execute it. It generates random …

c random srand
Recommended way to initialize srand?

I need a 'good' way to initialize the pseudo-random number generator in C++. I've found an article that states: In …

c++ random srand
Fill a vector with random numbers c++

I've got a vector that I'm trying to fill up with random numbers. I keep running into an issue however …

c++ random vector srand
srand() — why call it only once?

This question is about a comment in this question Recommended way to initialize srand? The first comment says that srand() …

c random srand
implicit declaration of function 'time' [-Wimplicit-function-declaration]|

Whenever I try to use srand function I get this warning "implicit declaration of function 'time' [-Wimplicit-function-declaration]|" and a windows …

c srand
How does srand relate to rand function?

I understand that rand() function generates the same number(s) each you run it if you don't change the seed …

c random srand
Implicit declaration of functions srand, rand and system

Trying to solve an exercise where I have to print a random temperature value between 35°C & -10°C every 5 …

c linux random system srand
rand() generating the same number – even with srand(time(NULL)) in my main!

So, I'm trying to create a random vector (think geometry, not an expandable array), and every time I call my …

c++ random srand
What is the best way to seed srand()?

The way I learned was to initially seed the random number generator with srand(time(NULL)) and then use calls …

c random srand
Is it modern C++ to use srand to set random seed?

For code that uses std::random_shuffle, I need to set a random seed so that the pseudorandom sequences produced …

c++ random c++11 srand