std::string str = "12,345,678,000";
이런식으로 문자열이 있을 때,
str.replace(",", "");
이런식으로 써서.. 쉼표를 다 지우고..
str == "12345678000"
로 만들려고 하는데..
오버로딩된 함수들을 찾아봐도 적절한게 없네요.. -_-;
어떤방법을 써야하나요?
string의 멤버함수로 한큐에 할 수는 없고 루프를 돌려야 합니다.
string str = "12,345,678,000"; string::size_type pos = str.find(','); while (pos != string::npos) { str.erase(pos, 1); pos = str.find(',', pos); }
#include <algorithm> #include <functional> using namespace std; str.erase(remove_if(str.begin(), str.end(), bind1st(equal_to<char>(), ',')), str.end());
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
string의 멤버함수로 한큐에 할 수는 없고 루프를 돌려야 합니다.
string의 멤버함수로 한큐에 할 수는 없고 루프를 돌려야 합니다.
한 문장으로 할 수도 있습니다.
댓글 달기