How to convert vector to array

后端 未结 10 1706
野的像风
野的像风 2020-11-22 09:20

How do I convert a std::vector to a double array[]?

10条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 09:30

    Vectors effectively are arrays under the skin. If you have a function:

    void f( double a[]);
    

    you can call it like this:

    vector  v;
    v.push_back( 1.23 )
    f( &v[0] );
    

    You should not ever need to convert a vector into an actual array instance.

提交回复
热议问题