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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. randomize

randomize

Scheduled Pinned Locked Moved C / C++ / MFC
c++game-devhelpquestionlounge
5 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Would anybody like to help me to produce a random number for my C++ guessing game?

    RaviBeeR D D 3 Replies Last reply
    0
    • L Lost User

      Would anybody like to help me to produce a random number for my C++ guessing game?

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      Sure. Here's one: 6410086356. Or you could use rand() and srand(). /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      N 1 Reply Last reply
      0
      • RaviBeeR RaviBee

        Sure. Here's one: 6410086356. Or you could use rand() and srand(). /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        N Offline
        N Offline
        Neville Franks
        wrote on last edited by
        #3

        I think 6410086356 is out by one.:-D Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com

        1 Reply Last reply
        0
        • L Lost User

          Would anybody like to help me to produce a random number for my C++ guessing game?

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

          If you are content with pseudo-random numbers, use rand().


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          1 Reply Last reply
          0
          • L Lost User

            Would anybody like to help me to produce a random number for my C++ guessing game?

            D Offline
            D Offline
            Dimenser
            wrote on last edited by
            #5

            srand((unsigned) time(NULL)); this is what I use to "seed" the random number generator. Otherwise the numbers won't be so random. number=(rand()%6)+1; this picks a random number 1-6. (0-5 until you get to the +1). :)

            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