I am working on a c++ problem where I need to convert a vector pair of type struct to an array. My code is as follows:
struct YObject
{
    YObject(unsigned int val1,
        float val2,
        float val3)
     : m_V1(val1)
     , m_V2(val2)
     , m_V3(val3)
    {}
    unsigned int m_V1;
    float m_V2;
    float m_V3;
};
int result(float *output)
{
  int output_size = 3*3;
 
  std::vector<YObject> vect;
       
    // using emplace() to insert pair in-place 
    vect.emplace_back(32, 24.5, 56.3); 
        
    vect.emplace_back(45, 30.3, 67.8);
    
    vect.emplace_back(99, 78.6, 59.3);
    
    float out[3];
    for (int i=0; i<vect.size(); i++)
    {
        out[0]=vect[i].m_V1;
        out[1]=vect[i].m_V2;
        out[2]=vect[i].m_V3;
      
        for (int n=0; n<3; n++)
        {
            output[n] = out[n];
            //cout << output[n] << endl;
        }
    
    }
return 0;
}
int final(float *outr)
{
    result(outr);
    return 0;
}
int main()
{
    int size = 3*3;
    float arr[size];
    final(arr);
    cout << "arr[0]: " << arr[0] << " arr[1]: " << arr[1] << " arr[2]: " << arr[2] << " arr[3]: " << arr[3] << " arr[4]: " << arr[4] << " arr[5]: " << arr[5] << " arr[6]: " << arr[6] << " arr[7]: " << arr[7] << " arr[8]: " << arr[8];
    return 0;
} 
I want that the output array passed in result function to return the full vector which is formed after three emplace_back statements. i.e. the cout statement in main function should print:
arr[0]: 32 arr[1]: 24.5 arr[2]: 56.3 arr[3]: 45 arr[4]: 30.3 arr[5]: 67.8 arr[6]: 99 arr[7]: 78.6 arr[8]: 59.3
but right now its printing:
arr[0]: 99 arr[1]: 78.6 arr[2]: 59.3arr[3]: 0 arr[4]: -1.94201e+27 arr[5]: 4.59121e-41 arr[6]: -9.96761e+17 arr[7]: -5.79801e+60 arr[8]: 1.98345e-22