Is There A Built-In Way to Split Strings In C++?

前端 未结 10 2237
心在旅途
心在旅途 2020-12-08 10:56

well is there? by string i mean std::string

10条回答
  •  臣服心动
    2020-12-08 11:32

    Yup, stringstream.

    std::istringstream oss(std::string("This is a test string"));
    std::string word;
    while(oss >> word) {
        std::cout << "[" << word << "] ";
    }
    

提交回复
热议问题