반응형
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 |
Tags
- event
- React
- leetcode
- Props
- BinaryTree
- bit
- map
- c++
- node.js
- state
- DP
- component
- Context
- array
- UE5
- MySQL
- route
- nodeJS
- routes
- JSX
- Callback
- css
- treenode
- server
- axios
- 비트연산
- queue
- Navigation
- count
- priority_queue
Archives
- Today
- Total
우사미 코딩
[C++ / istringstream] string 문자열을 공백문자를 기준으로 나누기 본문
반응형
1. 코드
#include <iostream> // std::cout
#include <sstream> // std::istringstream
using namespace std;
int main() {
string words = "I have a dream";
istringstream in(words);
int i = 0, n = words.size();
for (string s; in >> s; i++) {
cout << i << " : " << s << endl;
}
}
2. 출력결과
0 : I
1 : have
2 : a
3 : dream
반응형
'Programming (C++) > C++' 카테고리의 다른 글
| [C++] 알파벳 a-z ↔ 0-26 변환하는 방법 (int ↔ char) (0) | 2023.05.21 |
|---|---|
| [C++] ASCII를 사용하여 uppercase <-> lowercase 변환하기 (0) | 2023.05.21 |
| [C++] 10진수를 2진수로 출력하는 방법 - bitset (0) | 2023.04.19 |
Comments