How to cast vector to char*

前端 未结 4 990
粉色の甜心
粉色の甜心 2020-12-13 13:53

I have a buffer like this:

vector buf

How can I cast it to char*?

If I do:

(char *)buf
         


        
4条回答
  •  感情败类
    2020-12-13 14:45

    Try

    (char *)(&buf[0])
    

    or another, more C++ cast. But also tell us what you're using this for. It may be a bad idea.

提交回复
热议问题