http://www.cplusplus.com/reference/string/string/substr/
string::substr - C++ Reference
12345678910111213141516171819 // string::substr #include #include int main () { std::string str="We think in generalities, but we live in details."; // (quoting Alfred N. Whitehead) std::string str2 = str.substr (3,5); // "think" std::size_t pos = str.find
www.cplusplus.com
사용
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
ios::sync_with_stdio(false); cin.tie(NULL);
string str = "abcdefghijk";
for (int i = 0; i < str.length(); i++)
{
cout << str.substr(i) << '\n';
}
return 0;
}
|
결과
'팁' 카테고리의 다른 글
마크다운(Markdown) 에서 파일 연결하기 (마크다운에서 마크다운 파일 연결) (0) | 2022.01.10 |
---|---|
잊지 않기 위해 작성하는 comp함수 (1) | 2021.08.14 |
프로세스모델 작성중 (0) | 2021.04.26 |
16(Hax) 진법 덧셈 뺄셈에 대한 그냥 글 (0) | 2021.04.21 |
Notepad++ 플러그인(plugin) dll파일 적용법 & 노트패드에서 Vim 편집기 사용(?) (0) | 2020.11.22 |