Is it safe to pass std::string to C style APIs?

后端 未结 5 682
南笙
南笙 2021-01-04 23:16

It is well defined C++ to pass std::vector to C APIs that expect an output array like so because std::vector is contiguous:

std::vector myArray(a         


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-04 23:41

    Yes, but you'll need to pass them using the c_str method to guarantee null-termination.

提交回复
热议问题