64,647
社区成员
发帖
与我相关
我的任务
分享
cout << "Test 1" << endl;
char* bytes = "123456\0\0121212";
std::stringstream ss;
ss << bytes;
string str;
while (ss >> str)
{
std::cout << str << endl;
}
cout << endl;
cout << "Test 2" << endl;
bytes = "123456\0121212";
ss.str("");
ss.clear();
ss << bytes;
while (ss >> str)
{
std::cout << str << endl;
}
char* bytes = "123456\0\0121212";
写成
char bytes[] = {'1','2'...'6','\0','\0','1'...}
不要写成指针形式,也不要写成字符串形式,因为c++在字符串理解上面稍许不同。