What difference between rand() and random() functions?

后端 未结 7 1293
抹茶落季
抹茶落季 2020-12-05 07:58

Once, my teacher taught me to use randomize() and random() function for generating pseudorandom numbers in C++ Builder. Now I prefer working in VS

相关标签:
7条回答
  • 2020-12-05 08:34

    Although there are (obviously, above) people who will assert with religious fervor that rand() is bad and random() is not, it turns out that your mileage may vary. Here's the gcc answer to the question of "What's the difference...", as supplied by the gcc version of stdlib.h (emphasis added):

    /* These are the functions that actually do things. The random',srandom', initstate' andsetstate' functions are those from BSD Unices. The rand' andsrand' functions are required by the ANSI standard. We provide both interfaces to the same random number generator. / / Return a random long integer between 0 and RAND_MAX inclusive. */

    0 讨论(0)
提交回复
热议问题