title: c++ Is it possible to have a process (outside of main) that returns an array whose size is determined by the input, without using pointers or macros?
body: <p>Bellow is a simple program that works fine. It contains a function that is able to return a string of arbitrary size. The size of which is determined by the function input.</p>
  <pre><code>#include &lt;iostream&gt;                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                
  using namespace std;                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                
  string strFunc(int a){                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                
    string toBeReturned;                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                
    for(int i=0; i &lt; a; i++){                                                                                                                                                                                                                   
      toBeReturned += '!';                                                                                                                                                                                                                      
    }                                                                                                                                                                                                                                           
    return toBeReturned;                                                                                                                                                                                                                        
  }                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                
  int main(){                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                
    int x = 5;                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                
    cout &lt;&lt; strFunc(x) &lt;&lt; endl;                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                
    return 0;                                                                                                                                                                                                                                   
  }             
  
                                                                                                                                                                                                                              
  </code></pre>
  <p>If instead I wanted a function (or a single process to call in main) to return a 1-D array (<code>int toBeReturned[size to be determined]</code>) I had to use a function that returns a pointer and then include that function in a macro that constructs the array.</p>
  <p>Is there a simpler way of doing this in c++?</p>
  <p>If not can someone please explain why this only works for type string? I thought that a string is simply a 1-D array of type 'char'.</p>
  <p>Thank you,</p>
  <p>Daniel</p>