Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
一个简单的问题,如何创建一个函数,该函数接受 a并用 aunsigned char std::vector吐出 an 。谢谢!unsigned char[]length
unsigned char std::vector
unsigned char[]
length
啊,看来我的问题是我对 std::vector 的了解。我一直认为 std::vector 没有以线性方式保持其值。这解决了我的很多问题。谢谢!
只需使用:&v.front()。
&v.front()
如果您需要副本,请使用std::copy.
std::copy
不幸的是,它不是一个班轮,但也不算太糟糕:
std::vector<unsigned char> v(10); unsigned char* a = new unsigned char[v.size()]; std::copy(v.begin(), v.end(), a); delete [] a;