본문 바로가기
C++

using for with a string

by SpeeDr00t 2016. 7. 29.
반응형

using for with a string

1.source

#include <iostream>
#include <cstring>

using namespace std;

int main( int argc , char ** argv )
{
    string word = "black falcon";

    cout << endl;
    for( int i = strlen(word.c_str()) -1; i >= 0; i-- )
    {
        cout << word[i];
    }
    cout << endl;


return 0;
}

result

hacker@ubuntu:~/cpp$ !g
g++ -o forstr1 forstr1.cpp 
hacker@ubuntu:~/cpp$ ./forstr1 

noclaf kcalb
hacker@ubuntu:~/cpp$ 

반응형

'C++' 카테고리의 다른 글

Count Derangements  (0) 2016.08.03
point to string  (0) 2016.07.29
pointer  (0) 2016.07.28
hash string  (0) 2016.07.12
데이터 비교해서 sink 맞추기  (0) 2016.07.12