반응형
i2string : 숫자를 문자열로 변환
1.소스
#include <sstream> #include <string> #include <iostream> using namespace std; void i2string( int i , string & result ) { stringstream out; out.clear(); out << i; out >> result; } int main( int argc , char ** argv ) { string data; i2string( 100, data ); cout << data << endl; return 0; }
2.출력
hacker@HACKER:~/cpp$ g++ -o i2string i2string.cpp hacker@HACKER:~/cpp$ ./i2string 100
반응형
'C++' 카테고리의 다른 글
using for with a string (0) | 2016.07.29 |
---|---|
point to string (0) | 2016.07.29 |
pointer (0) | 2016.07.28 |
hash string (0) | 2016.07.12 |
데이터 비교해서 sink 맞추기 (0) | 2016.07.12 |