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.
簡単な質問です。 を取り出してをunsigned char std::vectorで吐き出す関数をどのように作成しますか。ありがとう!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;