C++文字列をスペースで区切って保存

963 ワード

元の文字列:str 1=「qwe bbb 333」出力結果:str 2=「qwe」、str 3=「bbb」、str 4=「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;
}