* Computer Science/C++

c++로 스플릿하기

soicem 2018. 9. 27. 20:26

 c++로 스플릿을 하려면 boost나 istringstream을 써야하는듯 하다.  istringstream을 사용해서 split하는 방법을 기록해둔다.


1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <sstream>
 
using namespace std;
 
int main(){
    int num;
    // string split in cpp
    istringstream iss("10 20 30 40");
    while (iss >> num) cout << num << " ";
    return 0;
}
 
cs


'* Computer Science > C++' 카테고리의 다른 글

list 짝수, 홀수 분리하기  (0) 2018.10.31
vector 비교하기  (0) 2018.10.02
stack with template  (0) 2018.05.28
Combination & memset  (0) 2018.04.04
2차원 벡터 생성  (0) 2018.03.30