Home Forums C Programming Beginner Help

Viewing 4 reply threads
  • Author
    Posts
    • #1989
      chucky
      Participant

      Hi, I’m new here and I’m also new to C++. And I mean literally new, as in I just started yesterday. I’ve read a few tutorials and learned somethings but I still know basically nothing. I’m making some simple programs to practice and the current one is a random number generator.
      Here is the code.

      If something looks dumb, I’ve already told you I only started yesterday. But the questions are instead of entering a to repeat, is there anyway to just push enter and have it repeat;and whenever I run this program, it will generate a random number, but every time I run it the random numbers are the same. For example this first random number I generate might be 134789 and the second might be 983038, which are completely random. But if you run the program again, the same numbers come up. Why does this happen and how do I fix it.Thanks!

    • #3240
      S.Thananchayan
      Participant

      You need loop to hit random off system time

    • #3241
      chucky
      Participant

      Thanks, it worked. What did the function you added do?

    • #3242
      chucky
      Participant

      Oh, so no one wants to help the noob? Come on people. What did whatever he added do?

    • #3243
      S.Thananchayan
      Participant

      Unless something random seeds Rand. Rand will generate the same random numbers every time. In this case were using your computers time.
      And every time you loop your system time is different So your numbers from say 3:43:01 to 3:43:02 will be different. Random enough for most applications.
      Read Beginning C++ Game Programming
      · ISBN-10: 1592002056
      · ISBN-13: 978-1592002054
      That’s where I learned that

Viewing 4 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.