原型:char *itoa(int value,char *string)
功能:将整数value转换成字符串存入string,默认为十进制;
说明:返回指向转换后的字符串的指针
#include<stdlib.h> #include<stdio.h> #include<assert.h> #include<stdbool.h> #include<string.h> #define SWAP(a,b) (a)^=(b);(b)^=(a);(a)^=(b) char* strReverse(char* str){ assert(str!=NULL);//if(NULL == str) return; char *front,*rear; front=rear=str; while(*rear) rear++; rear--; while(rear > front){ SWAP(*rear,*front); front++; rear--; } return str; } char* myitoa(int value,char* result){ assert(result!=NULL); bool isNegative=false; char* str = result; if(value<0){ isNegative=true; value*=-1; } do{ *str ++ = value % 10 + '0'; printf("result is:%c ",*(str-1)); }while(value /= 10); if(isNegative) *str++ = '-'; *str = '