所以normaly我做的東西,如:如何從std :: ifstream中將文件讀入unsigned char數組?
std::ifstream stream;
int buff_length = 8192;
boost::shared_array<char> buffer(new char[buff_length]);
stream.open(path.string().c_str(), std::ios_base::binary);
while (stream)
{
stream.read(buffer.get(), buff_length);
//boost::asio::write(*socket, boost::asio::buffer(buffer.get(), stream.gcount()));
}
stream.close();
我不知道如何讀入unsigned char
緩衝區(boost::shared_array<unsigned char> buffer(new unsigned char[buff_length]);
)
其中'reinterpret_cast <>'實際上是正確的方法。 – Chad 2012-04-26 14:29:54
此外,我更喜歡shared_ptr>爲shared_array –
2012-04-26 15:00:41