"C++ 문자열 ltrim() 구현"의 두 판 사이의 차이

 
31번째 줄: 31번째 줄:
* [[C++ 문자열 trim() 구현]]
* [[C++ 문자열 trim() 구현]]
* [[C++ 문자열 rtrim() 구현]]
* [[C++ 문자열 rtrim() 구현]]
* [[C++ 문자열 find_if()]]
* [[함수 ltrim()]]
* [[함수 ltrim()]]


[[분류: C++ 문자열]]
[[분류: C++ 문자열]]

2023년 9월 24일 (일) 15:25 기준 최신판

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  ]
}
#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(), [](char ch) { return ch!=' '; }));
    cout << '[' << s << ']'; // [Hello, World  ]
}

2 같이 보기[ | ]

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