Is there a way to find how many times the C library function rand() has been called during an execution of a program? The program is written by myself thus its code can be edited.
I can find how many times rand() is called using Visual Studio debugger. However, I found that my program produces different random number sequence when running outside the debugger. Thus I want to investigate the invocation times outside the debug开发者_运维技巧ger as well.
Thanks.
To produce the same set of random number just set the seed value to a predetermined value:
int main()
{
srand(0); // The random number sequence should now be deterministic.
// STUFF
}
精彩评论