title: Concatenate ints in an array?
body: <p>As part of a homework assignment I need to concatenate certain values in an array in C++. So, for example if I have:</p>
  
  <pre><code>int v[] = {0,1,2,3,4}
  </code></pre>
  
  <p>I may need at some point to concatenate v[1] -> v[4] so that I get an int with the value 1234.</p>
  
  <p>I got it working using stringstream, by appending the values onto the stringstream and then converting back to an integer. However, throughout the program there will eventually be about 3 million different permutations of v[] passed to my toInt() function, and the stringstream seems rather expensive (at least when dealing with that many values). it's working, but very slow and I'm trying to do whatever I can to optimize it.</p>
  
  <p>Is there a more optimal way to concatenate ints in an array in C++? I've done some searching and nearly everywhere seems to just suggest using stringstream (which works, but seems to be slowing my program down a lot).</p>
  
  <p>EDIT: Just clarifying, I do need the result to be an int.</p>