C++
using for with a string
SpeeDr00t
2016. 7. 29. 14:18
반응형
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$
반응형