Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. srandom and random

srandom and random

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestionlounge
9 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #1

    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 found

    the 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 ?

    P L D 3 Replies Last reply
    0
    • _ _Flaviu

      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 found

      the 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 ?

      P Offline
      P Offline
      phil o
      wrote on last edited by
      #2

      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."

      _ 1 Reply Last reply
      0
      • _ _Flaviu

        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 found

        the 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 ?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Take a look at C/C++ language and standard libraries reference | Microsoft Docs[^], where you will find all the C and C++ library references.

        1 Reply Last reply
        0
        • P phil o

          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."

          _ Offline
          _ Offline
          _Flaviu
          wrote on last edited by
          #4

          These tho two calls are coming from a Linux code ... and I didn't found documentation about them.

          1 Reply Last reply
          0
          • _ _Flaviu

            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 found

            the 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 ?

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Probably need to use srand() and rand().

            "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

            _ 1 Reply Last reply
            0
            • D David Crow

              Probably need to use srand() and rand().

              "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

              _ Offline
              _ Offline
              _Flaviu
              wrote on last edited by
              #6

              That worked. Thank you !!!

              K 1 Reply Last reply
              0
              • _ _Flaviu

                That worked. Thank you !!!

                K Offline
                K Offline
                k5054
                wrote on last edited by
                #7

                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)

                _ 1 Reply Last reply
                0
                • K k5054

                  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)

                  _ Offline
                  _ Offline
                  _Flaviu
                  wrote on last edited by
                  #8

                  I have tried to use srand_s and rand_s, but no one is recognized by my compiler:

                  error C3861: 'srand_s': identifier not found
                  error C3861: 'rand_s': identifier not found

                  V 1 Reply Last reply
                  0
                  • _ _Flaviu

                    I have tried to use srand_s and rand_s, but no one is recognized by my compiler:

                    error C3861: 'srand_s': identifier not found
                    error C3861: 'rand_s': identifier not found

                    V Offline
                    V Offline
                    Victor Nijegorodov
                    wrote on last edited by
                    #9

                    See the Remark section in [rand_s | Microsoft Docs](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rand-s?view=vs-2019)

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups