title: c++ using random numbers to decide the next encounter
body: <p><em>EDITED for full code</em>  </p>
  
  <p>I am trying to make a text based rpg game because im really bored and want to put my c++ "skills" at test xd.<br>
  But i am having a problem with the functions <code>srand</code> and <code>rand</code>, the function to generate random numbers.  </p>
  
  <p>What i want do achieve, is to let the RNG decide the next action of the game. I.e :</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  #include &lt;string&gt;
  #include "conio.h"
  #include &lt;time.h&gt;
  using namespace std;
  
  void GetRandom();
  
  int main()
  {
  int x;
  string name;
  srand(time(NULL));
  
  cout &lt;&lt; "welcome to adventurers world!" &lt;&lt; endl;
  cout &lt;&lt; "you wake up on an island far far away and you don't know where you are" &lt;&lt; endl;
  Sleep(2000);
  cout &lt;&lt; "Please enter the name of your adventurer" &lt;&lt; endl;
  getline(cin, name);
  cout &lt;&lt; "hello " &lt;&lt; name &lt;&lt; endl;
  Sleep(1000);
  cout &lt;&lt; "where would you like to go, " &lt;&lt; name &lt;&lt; " ?" &lt;&lt; endl;
  Sleep(1000);
  cout &lt;&lt; "1. waddle around the beach\n2. go to the cave straight ahead\n3. go into the forest" &lt;&lt; endl;
  cin &gt;&gt; x;
  if(x==1)
  {
      cout &lt;&lt; "you waddle abit around on the beach, and you suddenly " &lt;&lt; random;
  }
  
  _getch();
  }
  
  void random()
  {
  srand(time(NULL));
  int randnumber = rand() % 2 + 1;
  randnumber = randnumber;
  if(randnumber == 1)
  {
      cout &lt;&lt; "you encounter a mudcrab" &lt;&lt; endl;
  }
  else if (randnumber == 2)
  {
      cout &lt;&lt; "you find a stick" &lt;&lt; endl;
  }
  }
  </code></pre>
  
  <p>What i want do achieve here is, if the random number generated is 1 do (<code>randnumber == 1</code>) and if it is 2, do (<code>randnumber == 2</code>)<br>
  but instead it just gives me a hexidecimal as output.  </p>
  
  <p>is my code properly written? am i using the right expression for <code>srand</code>, calculation <code>w/e</code>. </p>
  
  <p>And is this even possible to do? or do i have to write it out manually what will happen next, which wont make it as much a dynamic game.  </p>
  
  <p>thanks for your help and time</p>