example 123456789 返回char 123456789 itostring函数编写

example 123456789 返回char 123456789

#include <stdio.h>
#include <stdlib.h>

char b[32]={0};
char a[32]={0};
char *iToString( int iVal )
{
    int i=0,j=0;
    int temp;

    while( iVal > 0 ){
       a[i] = (iVal % 10) + 0x30;
       i++;
       iVal = iVal /10;
    }//end of while
    temp = 1;
    for(j=0; j< i; j++){
        b[j] = a[i-temp];
        temp++;
    }
    return b;
}

int main()
{
    printf("%s\n", iToString(123456789));
    return 0;
}
posted @ 2017-08-19 18:14  夏海风  阅读(294)  评论(0)    收藏  举报