C++ 문자열 ltrim() 구현

Jmnote (토론 | 기여)님의 2023년 9월 24일 (일) 15:19 판 (새 문서: ==개요== ;C++ trim() 구현 ;C++ 문자열 trim() 구현 <syntaxhighlight lang='cpp' run> #include <iostream> #include <vector> #include <algorithm> using namespace std; int main...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

C++ trim() 구현
C++ 문자열 trim() 구현
#include <iostream>
#include <vector>
#include <algorithm> 
using namespace std;

int main() {
    string s = "  Hello, World  ";
    s.erase(s.begin(), find_if(s.begin(), s.end(), [](unsigned char ch) { return !isspace(ch); }));
    cout << '[' << s << ']'; // [Hello, World  ]
}

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}