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