I got a problem with the following code:
#include <iostream>
using namespace std;
double* FillArray(void) 
{   
    double result[5]; 
    for (int i = 0; i<5;i++){
        result[i]=(double) i;
    }
    return result; // return the pointer
}
int main()
{   
    double * a = FillArray();
    for (int i = 0; i<5;i++){
        cout << a[i] << endl; // print out the array
    }
    return 0;
}
The outputs are strange:
0
3.47187e-236
8.89753e-308
8.8976e-308
3.90251e-236
Could you tell what wrong in my code? I tried to use a function to return an array, and print out it in the main().
 
     
     
     
    