title: Why can't I iterate through an array in C++ and push_back items to a string?
body: <p>I am sure there is a better way of doing this, but right now I'm stuck on why it doesn't work. I am very new at coding... and have been Googling for an hour trying to figure it out, and just can't. What am I doing wrong?</p>
  <p>This is a Codewars challenge. One comment about the challenge said this:</p>
  <blockquote>
  <p>&quot;I didnt realize that I knew nothing about const keyword. Spent most
  of the time figuring out why I couldn't iterate through it or assign
  it to a string variable.&quot;</p>
  </blockquote>
  <p>Maybe that's my problem too?</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  std::string createPhoneNumber(const int arr[10]){
      
      string number;
  
      number.push_back('(');
      for (int i = 0; i &lt; 2; i++) {
        number.push_back(arr[i]);
      }
      number.push_back(')');
      number.push_back(' ');
      for (int i = 3; i &lt; 5; i++) {
        number.push_back(arr[i]);
      }
      number.push_back('-');
      for (int i = 6; i &lt; 9; i++) {
        number.push_back(arr[i]);
      }
  
   return number;
  }
  
  int main() {
    int arraySend[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
    
  cout &lt;&lt; createPhoneNumber(arraySend);
  
  return 0;
  }
  </code></pre>