Menu ▾ ▴

random library

Anonymous
2002-11-30
6 days ago
  • Anonymous

    Anonymous - 2002-11-30

    I am a rather inexperienced programmer working on a program for a class which is a dice game.  To play this I need to randomize my dice.  So in my include statements I entered "#include <random.h>".  This gives me no errors when I compile, but when I try to use the "randomize()" command in one of my functions I receive the error: "implicit declaration of function".  I also get this error when I try to make my dice random by stating "int dice1  = random(6) + 1". 

     
    • Anonymous

      Anonymous - 2002-11-30

      If it makes any difference, I am using a different random library than the one that comes with Dev-Cpp.

       
    • upcase

      upcase - 2002-12-13

      It's been a while since I randomized something, but here's a very brief explanation, mainly C but should work in C++ none the less:

      #inculude <iostream>
      #include <stdlib.h>
      #include <time.h>
      using namespace std;
      int  main()
      {   srand(time(NULL)); //set randomizer seed
          int dice1 = rand()%6+1;
          cout << "Result: " << dice1 << endl;
          return 0;
      }

      Hope this is what you were looking for. I'm not sure but using standard functions I never heard of "randomize()" or "random()". Used these in Pascal as far as I remember. Use srand() to initialize the randomizer and rand() to actually get a random number.

      Hope this helps...
      Bye

       
  • Emma Brown

    Emma Brown - 6 days ago

    Spilleautomater med fallende symboler er faktisk en ganske kul idé. I stedet for at alt stopper etter én gevinst, forsvinner symbolene og nye faller ned. Jeg kunne godt tenkt meg å finne en slik variant blant spillene på nvcasino . Det gjør at ett enkelt spinn kan bestå av flere små runder. Synes egentlig det virker mer spennende enn når hjulene bare stopper og alt er over med en gang.

     

Log in to post a comment.