[C++, ์ฝํ ์ฉ] String split, parsing ํจ์
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(){
string s1 = "AAA BBB CCC";
string s2 = "AAA,BBB,CCC";
istringstream ss1(s1);
istringstream ss2(s2);
string stringBuffer1;
string stringBuffer2;
while(getline(ss1, stringBuffer1, ' ')){
cout<<stringBuffer1<<' '; //AAA BBB CCC
}
cout<<'\n';
while(getline(ss2, stringBuffer2, ',')){
cout<<stringBuffer2<<' '; //AAA BBB CCC
}
}
'Algorithm ๐ง๐ปโ๐ป > Note' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[C++, ํ ํ๋ฆฟ] ํ๋ก์ด๋-์์ฌ (0) | 2022.05.13 |
---|---|
[C++, ์ ์ฉํ ๋ฌธ๋ฒ] upper_bound, lower_bound (0) | 2022.05.11 |
[C++, ํ ํ๋ฆฟ] ์์ ๊ตฌํ๊ธฐ(์๋ผํ ์คํธ๋ค์ค์ ์ฒด) (0) | 2022.04.11 |
[C++, ์ ์ฉํ ๋ฌธ๋ฒ] ๋ฌธ์์ด ๋์๋ฌธ์ ๋ณํ (0) | 2022.04.10 |
[C++, ์ ์ฉํ ๋ฌธ๋ฒ] ํน์ ๋ฌธ์ ์นํ regex_replace (0) | 2022.04.09 |
[C++, ์ ์ฉํ ๋ฌธ๋ฒ] String to CharArray (0) | 2021.11.07 |
๋๊ธ