c·c++/c++ 프로그래밍
sstream의 활용 - sscanf
바로이순간
2012. 5. 16. 16:57
#include<iostream>
#include<string>
using namespace std;
int main(){
int a=123;
string str;
str=a;
cout<<"\n "<<str[0];
return 0;
}
여기서 str[0]=1
str[1]=2
str[2]=3
이렇게 안되나요?
-----------------------------------------------------------------------------
#include <iostream> #include <sstream> #include<string> using namespace std; int main(){ int a=123; string str; stringstream ss; ss<<a; str=ss.str(); cout<<endl<<str[0]<<" "<<str[1]<<" "<<str[2]; return 0; } 위와 같이 하면 됩니다.