본문 바로가기
프로그래밍 _공부자료./C++ 공부

c++ string 문자열 자르기

by 대구부자 2023. 2. 17.
반응형

#include <iostream>
#include <sstream>
#include <string>

int main() {
    std::string s = "1230456789"; // example string
    std::stringstream ss(s); // create a stringstream with the string
    std::string token;
    while (getline(ss, token, '0')) { // split the string based on '0' character
        std::cout << token << std::endl;
    }
    return 0;
}


c++ string 문자열 원하는 조건으로 문자열 나누기
가장 편한방법

반응형

댓글