본문 바로가기

Development

[STL/string] 문자열 뒤집기

#include <iostream.h>
#include <stdlib.h>
#include <string>
#include <algorithm>  //reverse()

int main()
{
    char buf[100] = "I am a Boy!";
    string str = buf;

    cout << buf << endl;
    cout << str << endl;
    cout << "-----reverse-----" << endl;

    // 문자열 뒤집기
    reverse( str.begin(), str.end() );
    strcpy(buf, str.c_str() );

    cout << buf << endl;
    cout << str << endl;

    // 뒤집어서 출력하기.
    copy( str.rbegin(), str.rend(), ostream_iterator<char>(cout) );
    cout << endl;

    cin.get();
    return 0;
}

'Development' 카테고리의 다른 글

[역공학] OnlyDbg PlugIn Site  (0) 2008.12.01
[Development] FPS 구하기 ( Frame Per Second )  (0) 2008.11.30
[Windows]98에서 정상작동하는 TransparentBlt  (0) 2008.11.03
[Development]WinMgr  (0) 2008.10.21
dll 관련  (0) 2008.10.19