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. Random numbers

Random numbers

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++questionlounge
11 Posts 5 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.
  • C Offline
    C Offline
    Calin Negru
    wrote on last edited by
    #1

    How do you generate random numbers in C++? I C# I had to use a seed and set some range limits/boundaries. .

    _ L CPalliniC 3 Replies Last reply
    0
    • C Calin Negru

      How do you generate random numbers in C++? I C# I had to use a seed and set some range limits/boundaries. .

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

      With rand - C++ Reference[^] function. You can find there few examples.

      C 1 Reply Last reply
      0
      • C Calin Negru

        How do you generate random numbers in C++? I C# I had to use a seed and set some range limits/boundaries. .

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

        A google search would have found the answer quicker than it takes to open a question here. Please try doing a bit of research first.

        C 1 Reply Last reply
        0
        • L Lost User

          A google search would have found the answer quicker than it takes to open a question here. Please try doing a bit of research first.

          C Offline
          C Offline
          Calin Negru
          wrote on last edited by
          #4

          k, I`ll keep that in mind next time I post. I still believe in learning by human interaction though.

          https://web.facebook.com/pin46/

          L 1 Reply Last reply
          0
          • C Calin Negru

            k, I`ll keep that in mind next time I post. I still believe in learning by human interaction though.

            https://web.facebook.com/pin46/

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

            Keep it in mind before you post. And if you really want to learn a language there are many useful books and tutorials you can make use of.

            C 1 Reply Last reply
            0
            • _ _Flaviu

              With rand - C++ Reference[^] function. You can find there few examples.

              C Offline
              C Offline
              Calin Negru
              wrote on last edited by
              #6

              Thanks

              J 1 Reply Last reply
              0
              • L Lost User

                Keep it in mind before you post. And if you really want to learn a language there are many useful books and tutorials you can make use of.

                C Offline
                C Offline
                Calin Negru
                wrote on last edited by
                #7

                Ok

                1 Reply Last reply
                0
                • C Calin Negru

                  Thanks

                  J Offline
                  J Offline
                  Joe Woodbury
                  wrote on last edited by
                  #8

                  Do NOT use rand. See <random> - C++ Reference[^]

                  1 Reply Last reply
                  0
                  • C Calin Negru

                    How do you generate random numbers in C++? I C# I had to use a seed and set some range limits/boundaries. .

                    CPalliniC Online
                    CPalliniC Online
                    CPallini
                    wrote on last edited by
                    #9

                    You may use either the legacy rand()[^] function (with the srand one you might provide the seed), or the classes provided by the 'new' random header[^]. The latter is more sophisticated and has a somewhat more difficult interface. You might look at code samples, though, for instance, see the code in this page[^].

                    In testa che avete, signor di Ceprano?

                    C 1 Reply Last reply
                    0
                    • CPalliniC CPallini

                      You may use either the legacy rand()[^] function (with the srand one you might provide the seed), or the classes provided by the 'new' random header[^]. The latter is more sophisticated and has a somewhat more difficult interface. You might look at code samples, though, for instance, see the code in this page[^].

                      C Offline
                      C Offline
                      Calin Negru
                      wrote on last edited by
                      #10

                      Thank you CPallini

                      my name is Calin Negru, I also post on GameDev.net

                      CPalliniC 1 Reply Last reply
                      0
                      • C Calin Negru

                        Thank you CPallini

                        my name is Calin Negru, I also post on GameDev.net

                        CPalliniC Online
                        CPalliniC Online
                        CPallini
                        wrote on last edited by
                        #11

                        You are welcome.

                        In testa che avete, signor di Ceprano?

                        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