1 개요
- C++ 문자열 split() 구현
C++
CPU
0.4s
MEM
56M
0.5s
Copy
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main() {
string s = "abc,defgh,ijk";
vector<string> strs;
istringstream iss(s);
for (string s; getline(iss, s, ','); ) {
strs.push_back(s);
}
for (string str: strs) {
cout << str << ' '; // abc defgh ijk
}
}
abc defgh ijk
2 같이 보기
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.