我靠,linux 下的 itoa() 函数还得自己写
#include <ctype.h>#include <stdio.h>
void itoa (int n,char s[]);
//atoi 函数:将s转换为整形数
int main(void )
{
int n;
char s;
printf("Input n:\n");
scanf("%d",&n);
printf("the string : \n");
itoa (n,s);
return 0;
}
void itoa (int n,char s[])
{
int i,j,sign;
if((sign=n)<0)//记录符号
n=-n;//使n成为正数
i=0;
do{
s=n%10+'0';//取下一个数字
}while ((n/=10)>0);//删除该数字
if(sign<0)
s='-';
s='\0';
for(j=i;j>=0;j--)//生成的数字是逆序的,所以要逆序输出
printf("%c",s);
} 这玩意本来就不是ansi c标准的。
页:
[1]