标签: c++ std
让char *及其int length如何深入复制到stringstream?
char *
int length
stringstream
答案 0 :(得分:3)
使用std::stringstream::write(s, length);。
std::stringstream::write(s, length);
请注意,如果char*为空终止operator<<(),则可以使用length,而不需要提供std::stringstream s; const char* buf = "hello"; s << buf; :
char*
operator<<()
length
std::stringstream s; const char* buf = "hello"; s << buf;
{{1}}
答案 1 :(得分:1)
不应该满足您的要求吗?
http://www.cplusplus.com/reference/ostream/ostream/write/
答案 2 :(得分:1)
您应该阅读doc和此one