I'm not quite sure how to phrase this question, but I couldn't find any others like it.
Say I have this code:
srand(1);
srand(SOME_DEFINED_CONST_INT);
If I run this executable on a number of different physical machines, is the sequence of rand()
guaranteed to be consistent between them? i.e. if I get 1, 4, 6, 3, 4
on one machine, will I always get that same sequence on the others?
If yes, how can that be proven? Is it part of the standard?
If no, is there anything I could do to make it so?
No, the standard guarantees no such thing. However, the logic of generating the random numbers is inside the C standard library. So if you build the application with the same version of the library, the sequence should be the same. The second part of my answer is just a guess, but the standard definitely doesn't give any guarantees.