// convert.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <vector>
using namespace std;
string convert(int *result,int n)
{
vector<char> vec;
//将数n逆序后,存放到数组result中
while(n)
{
*result = n % 10;
vec.push_back((char)(*result+'0'));
n=n/10;
result+=1;
}
string str;
str.assign(vec.begin(),vec.end());
return str;
}
int main(int argc, char* argv[])
{
int a[10];
int n=12345;
string s=convert(a,n);
for (int i=0;i<5;i++)
{
printf("%d,",a[i]);
}
printf("\n%s\n",s.c_str());
return 0;
}
/*
5,4,3,2,1,
54321
Press any key to continue
*/