이번엔 문자열 다루는 알고리즘 들이다.
C++ 기본 라이브러리에서 당연히 지원 해줄것 같은데 안해주는(...) 문자열 관련 함수들을 담고 있다.
첫번째로 대소문자 변경 기능만 살펴본다.

String 알고리즘은 원본을 변형하는 형태와, 원본을 보존하고 새로운 문자열을 리턴하는 두가지 형태로 지원되는점이 특징이다.

#include <string>

#include <boost/algorithm/string.hpp>

 

using namespace std;

using namespace boost;

 

int _tmain(int argc, _TCHAR* argv[])

{

        string str = "Hello Lyn!";

        string str2;

        printf("%s\n", str.c_str());

 

        to_upper(str); //모두대문자로바꾼다

        printf("%s\n", str.c_str());

        to_lower(str); //모두소문자로바꾼다

        printf("%s\n", str.c_str());

       

        str = "Hello Lyn!";

        str2 = to_upper_copy(str); //모두대문자로바꾸되원본을변형하지않고새로운문자열을리턴

        printf("%s %s\n", str.c_str(), str2.c_str());

        str2 = to_lower_copy(str); //모두소문자로바꾸되원본을변형하지않고새로운문자열을리턴

        printf("%s %s\n", str.c_str(), str2.c_str());

 

        return 0;

}

조회 수 :
15374
등록일 :
2009.05.12
11:39:09 (*.149.217.155)
엮인글 :
http://www.lunapiece.net/3804/9fe/trackback
게시글 주소 :
http://www.lunapiece.net/3804
문서 첨부 제한 : 0Byte/ 10.00MB
파일 제한 크기 : 10.00MB (허용한 확장자만 첨부할 수 있습니다.(관리자는 제외) : *.*)
옵션 :
:
:
:
:
List of Articles
번호 제목 글쓴이 날짜 조회 수
13 [Boost 살펴보기] 7. String Algorithm2 Lyn 2009-05-20 14374
» [Boost 살펴보기] 6. String Algorithm1 Lyn 2009-05-12 15374
11 [Boost 살펴보기] 5. lexical_cast file Lyn 2009-05-12 15661
10 [Boost 살펴보기] 4. multi_array Lyn 2009-05-11 14897
9 [Boost 살펴보기] 3. timer Lyn 2009-05-11 14905
8 [Boost 살펴보기] 2. any Lyn 2009-05-11 13844
7 [Boost 살펴보기] 1. pool file Lyn 2009-05-11 14455
6 프로그래밍 대회 알고리즘 파트 문제 [2] secret Lyn 2008-11-21 15485
5 컨테이너가 파괴될 때 소유한 객체 자동으로 파괴하기 Lyn 2008-10-22 13210
4 [TR1 살펴보기] 3. UnOrdered Containers Lyn 2008-10-05 14319
3 [TR1 살펴보기] 2. Array Lyn 2008-10-05 14256
2 [TR1 살펴보기] 1. Random Lyn 2008-10-05 14696
1 Delphi 2009 Generic 살펴보기 [1] Lyn 2008-09-29 12696

SITE LOGIN :)