#include <iostream>

#include <istream>

#include <streambuf>

#include <string>

#include <sstream>

using namespace boost;

using namespace std;


int main() {


int val;

stringstream ss(stringstream::in | stringstream::out | stringstream::binary);

unsigned char buffer[20];

unsigned char in[5] = { 0xAA, 0xBB, 0x00, 0xDD, 0xEE };

ss << in;

ss >> buffer;

printf("%x %x %x %x %x",buffer[0],buffer[1],buffer[2],buffer[3],buffer[4]);

return 0;

}


그럼 출력은 당연히 aa bb 00 dd ee 인줄 알았는데 바이너리 모드라서


개뿔


aa bb 00 cc cc 뜸


널값에서 끊어버림


스트링스트림 대신 바이너리스트림으로 쓸만한 스트림 추천점