STUDY/C++

[C++] istringstream 사용하여 문자열 자르기

yegyeom 2022. 5. 29. 01:54
#include <iostream>
#include <sstream>
using namespace std;

int main(){
    string str = "abc-def-ghi";
    
    istringstream iss(str);
    string buffer;
    
    while(getline(iss, buffer, '-')) cout << buffer << '\n';
    
    return 0;
}