C++将字符串按空格分开并分别保存

原字符串:str1 = “qwe bbb 333”
输出结果:str2 = “qwe” , str3 = “bbb” , str4 = “333”

#include 
#include 
#include 
using namespace std;
int main()
{
    string str1 = "qwe bbb 333";
    string str2,str3,str4;
    istringstream is(str1);
    is>>str2>>str3>>str4;
    cout<","<","<return 0;
}

你可能感兴趣的:(c++)