title: How to return array in C++?
body: <p>Why does the following code not work? </p>
  
  <p>It compiles fine but output is something like an address if I write <code>f</code> using <code>*</code> and the output is <code>0</code> if I write <code>f</code> without <code>*</code>.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include&lt;cstring&gt;
  using namespace std;
  using std::size_t;
  int *f(size_t s){
      int *ret=new int[s];
       for (size_t a=0;a&lt;s;a++)
            ret[a]=a;
        return ret;
        }
  int main(){
  
      size_t s=20;
      cout&lt;&lt;*f(s)&lt;&lt;endl;
  
      return 0;
  }
  </code></pre>