title: C++, function to return array as string
body: <p>I am new to C++ and am trying to make a function that takes an array of numbers and converts those numbers into the ASCII character, i.e. int to string. When I try to output the string however I get random characters. I have searched tutorials and a suggestion was that I should add a string terminator, which I did, but it doesn't seem to fix it and I can't find an answer that would solve this.</p>
  
  <p>i.e. I want the below code to print "Hello".</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  char* intToString(int* array, int size)
  {
      char string[size + 1];
      string[size] = '\0';
      for (int i = 0; i &lt;= size; i++)
          string[i] = array[i];
  
      return string;
  }
  
  
  int main()
  {
      int my_array[5] = {72, 101, 108, 108, 111};
      int size = 5;
      std::cout &lt;&lt; intToString(my_array, size);
  
      return 0;
  }
  </code></pre>