template
inline T TrimStr_Generic(const T& Src, const T& c) { int p2 = Src.find_last_not_of(c); if (p2 == T::npos) return T(); int p1 = Src.find_first_not_of(c); if (p1 == T::npos) p1 = 0; return Src.substr(p1, (p2-p1)+1); } char* trim(char *source) { std::string str(source); str = TrimStr_Generic
(str, "\r"); str = TrimStr_Generic
(str, "\n"); str = TrimStr_Generic
(str, "\t"); str = TrimStr_Generic
(str, " "); strcpy_s(source, str.length() + 1, str.c_str()); return source; }
" testing 134 \r\n" ==> "testing 134"
C++
trim
공백제거
템플릿
함수
Retrieved from http://hyacinth.byus.net/moniwiki/wiki.php/C++/공백제거 trim
last modified 2011-05-13 11:31:53