#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; } 위와 같이 하면 됩니다.
'c·c++ > c++ 프로그래밍' 카테고리의 다른 글
숫자열에서 한숫자씩 입력받기 (0) | 2012.07.08 |
---|---|
패스워드 파일을 읽고 처리하는 간단한 예제 (0) | 2012.05.29 |
소수점이 포함된 진법변환 (0) | 2012.04.24 |
열린 문의 갯수 (0) | 2012.04.16 |
width, precision (0) | 2012.03.31 |