본문 바로가기

STL에서 문자열 트림 (string trim)하기 STL에서 문자열 트림 (string trim)하기 Writer: http://ospace.tistory.com/ (ospace114@empal.com) 2008.08.13 아래 코드는 timebird님의 코드를 약간 수정하였다. 좀더 간편하고 축약하였다. namespace를 정해준 것은 동일 이름의 함수가 겹칠수 있기에 네임스페이스를 사용했다. 아래 경우는 기본 공배를 제거해주는 기능과 원하는 문자를 제거해주는 방법을 사용할 수 있다. #define TRIM\_SPACE " \\t\\n\\v" namespace ospace { inline std::string trim(std::string& s,const std::string& drop = TRIM_SPACE) { std::string r=s.eras.. 더보기
Vectors in STL Vectors in STL It’s a dynamic array that the stardard does not specify. Header file : Declaretion: namespace std { template class vector; } Vector opertions Create, Copy, and Destory Operations Operation Effect vector c Creats an empty vector without any elements vector c1(c2) Create a copy of another vector of the same type (all elements are copied) vector c(n) Creates a vector with n elements .. 더보기
[c/c++] 구조체 복제에 대한 이야기 가지고 있는 자료을 똑같은 복제본을 만들어야 될때는 매우 많다. 수십가지 데이터 혹은 수십개의 트리로 구성된 구조체를 일일히 하나씩 값을 넣는 다는 것은 곤혹스러운 일이 아닐 수 없다. 다음은 구조체에 대한 것으로 구조체를 복사하는 것에 대한 내용을 다루겠다. 작성자: ospace (ospace114 at empal.com) ospace.tistory.com/ 전형적인 구조체 복제 전형적인 구조체 복제 사용법은 다음과 같다. struct tag_Sport { TCHAR* pName; TCHAR pPlayer[10]; int score; }; int main() { tag_Sport soccer0 = {NULL, _T("Ospace"), 0}; tag_Sport soccer1; TCHAR name[] = .. 더보기

반응형