title: Generating random word made of letters and digits
body: <p>Im looking for help with my code. Im doing app, that will be downloading random images from Imgur.com, and I've stuck on their names generator. </p>
  
  <p>This is the code, that I have </p>
  
  <pre><code>char letter;
  unsigned short int asciiCode = 0;
  std::string imageName = "";
  std::ofstream fileToStoreImageNames;
  
  
  if (!fileToStoreImageNames.is_open())
      return -1;
  
  
  for (auto i = 0; i &lt; 6; i++)
  { 
      /* if getTrueOrFalse()==0 return capitalLetter() if not return smallLetter() */
      asciiCode = random.getTrueOrFalse() == 0 ? random.upperCase() : random.lowerCase();
      letter = static_cast &lt;char&gt;(asciiCode);
      if (imageName.size() &gt; 0)
          imageName += letter;
      else
          imageName = letter;
  }
  fileToStoreImageNames &lt;&lt; imageName &lt;&lt; std::endl;
  </code></pre>
  
  <p>I made some generators, that are returning numbers from defined range(in case of random.upperCase() it is range of 65 to 90), there is 50% chance for upperCase and 50% for lowerCase. Later im converting those numbers by static_cast to char.
   For now Im only writing those names to file, and I can see it isnt working as intended. If i just compile this code, It is writing to file something like</p>
  
  <p><code>bbbbbb
  rrrrrr
  YYYYYY
  vvvvvv
  UUUUUU
  EEEEEE
  rrrrrr</code>
  but, when I debug it step by step, it is working as it should be and I get random letters. <a href="http://i.imgur.com/Qnk3KBa.png" rel="nofollow">There</a> is my file after 11 attempts, lines 8 and 11, are result of step by step debugging. </p>