#include <stdio.h> char *my_itoa(int a,char *buffer, int buff_size) { char *temp; int b; temp = buffer; b = a; if (buffer == NULL) return NULL; while (a > 0) { if (buff_size < 1) return NULL; b = a%10; *temp = b + '0' ; temp++; a = a/10; buff_size--; } *temp = '\0'; /*Note : You have to Add a String reverse Function on this buffer here*/ return buffer; } /*sample Program*/ main() { char *str; int a ; a = 324; str = (char *) malloc(100); str = my_itoa (a,str,100); printf ("String is %s\n",str); }
2013年8月21日 星期三
整數轉字串

訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言