title: How to bind numbers together into an integer without addition?
body: <p>For example:
  If I end up with multiple digits and all of those numbers are generated randomly (1-9) up to 7 digits total and I want them all to end up as a whole integer, how do I go by doing this?</p>
  <p>Here is something I have tried:</p>
  <pre><code>static void generate_key(std::map&lt;std::string, int&gt;&amp; key, std::string c_user)
  {
      unsigned int hold[7]{}; // will hold all the random integers seperate to add onto final
      int *final = new int; // will store a complete 7 digit integer here later on
  
      for (int i = 0; i &lt; 7; i++)
      {
          unsigned int num = rand() % 9;
          hold[i] = num;
      }
  
      *final = hold[0] + hold[1] + hold[2] + hold[3]; // I know this sums everything but how do I get it to just add all the numbers into a single integer?!
      key.emplace(c_user, final);
  
      std::cout &lt;&lt; &quot;Key created: &quot; &lt;&lt; *final &lt;&lt; '\n';
  
      delete final;
  }
  </code></pre>
  <p>Hold all integers seperate from eachother:</p>
  <pre><code>unsigned int hold[7]{};
  </code></pre>
  <p>Create random digits:</p>
  <pre><code>for (int i = 0; i &lt; 7; i++)
          {
              unsigned int num = rand() % 9;
              hold[i] = num;
          }
  </code></pre>
  <p>Store and add all integers into <code>*final</code> integer</p>
  <pre><code>int *final = new int;
  </code></pre>
  <p>I want to generate a 7 digit key and each of every single digit is randomized. I then want to add them all up to make a whole integer that gets put into a map where a string has already been created and that key will represent the string. Do you get what I'm saying here? Sorry if my explanation is terrible I'm just too lost here..</p>
  <p>Here is the full code if thats helpful:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;map&gt;
  #include &lt;vector&gt;
  #include &lt;stdlib.h&gt;
  
  class Account
  {
  private:
      std::string username;
      std::string password;
  public:
      Account(std::string username, std::string password)
      {
          this-&gt;username = username;
          this-&gt;password = password;
      }
      ~Account() {};
  
      std::string get_username()const { return username; }
      std::string get_password()const { return password; }
  };
  
  static void create_account(std::string user, std::string pass, std::vector&lt;Account&gt; &amp;acc)
  {
      Account *account = new Account(user, pass);
  
      acc.push_back(*account);
  
      delete account;
  }
  
  static void generate_key(std::map&lt;std::string, int&gt;&amp; key, std::string c_user)
  {
      unsigned int hold[7]{};
      int *final = new int;
  
      for (int i = 0; i &lt; 7; i++)
      {
          unsigned int num = rand() % 9;
          hold[i] = num;
      }
  
      *final = hold[0] + hold[1] + hold[2] + hold[3];
  
      key.emplace(c_user, final);
  
      std::cout &lt;&lt; &quot;Key created: &quot; &lt;&lt; *final &lt;&lt; '\n';
  
      delete final;
  }
  
  std::vector&lt;Account&gt; accounts;
  std::map&lt;std::string, int&gt; keys;
  
  int main()
  {
      srand(time(NULL));
  
      create_account(&quot;random&quot;, &quot;triathlon&quot;, accounts);
      generate_key(keys, accounts[0].get_username());
  
      return 0;
  }
  
  static void create_account(std::string, std::string, std::vector&lt;Account&gt; &amp;acc);
  static void generate_key(std::map&lt;std::string, int&gt;&amp;, std::string);
  </code></pre>