How to convert vector to array

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

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

10条回答
  •  無奈伤痛
    2020-11-22 09:31

    vector thevector;
    //...
    double *thearray = &thevector[0];
    

    This is guaranteed to work by the standard, however there are some caveats: in particular take care to only use thearray while thevector is in scope.

提交回复
热议问题