| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- Substring with Concatenation of All Words
- Regular Expression
- iterator
- 43. Multiply Strings
- 운영체제
- Python Code
- LeetCode
- 파이썬
- 컴퓨터의 구조
- 시바견
- Protocol
- Python
- 30. Substring with Concatenation of All Words
- kaggle
- 109. Convert Sorted List to Binary Search Tree
- 715. Range Module
- concurrency
- Generator
- data science
- attribute
- DWG
- Convert Sorted List to Binary Search Tree
- shiba
- 315. Count of Smaller Numbers After Self
- Python Implementation
- t1
- 프로그래머스
- 밴픽
- Decorator
- Class
Archives
- Today
- Total
Scribbling
[C++] 전문가를 위한 C++ - Chapter 2 본문
1. String
substr(pos, len)
find(str)
replace(pos, len, str)
starts_with(str)
ends_with(str)
int main() {
string str{ "Hello!" };
if (str.find("!") != string::npos) {
cout << str << endl;
}
}
2. Number to String
int main() {
long double d{ 3.14L };
string s{ to_string(d) };
}
3. String to Number
int stoi(const string& str, size_t* idx=0, int base=10);
long stol(const string& str, size_t* idx=0, int base=10);
...
4. String_view
string_view is a new feature in C++17 - it is an efficient method to get a substring of the given string; it does not copy the string nor can modify it.
string_view func(string_view sv) {
return sv.substr(sv.rfind('.'));
}
int main() {
string filename{ "C:\\temp\\my file.txt" };
cout << func(filename) << endl;
cout << "string"s + func(filename).data() << endl;
}
5. format
int main() {
int i{ 10 };
auto s2{ format("Read {0} bytes from {1}", i, "file1.txt" )};
cout << s2 << endl;
}'Computer Science > C++' 카테고리의 다른 글
| [C++] find, deque, bfs, structured binding (0) | 2023.09.30 |
|---|---|
| [C++] Smart pointers (0) | 2023.09.30 |
| [C++] 2d DP table with vector (0) | 2023.09.19 |
| [C++] 전문가를 위한 C++ - Chapter 1 (0) | 2023.09.15 |
| [C++] vector<vector<int>> sorting with comparator (0) | 2023.09.07 |