请注意,上述函数与ANSI标准是不兼容的。能将整数转换为字符串而且与ANSI标准兼容的方法是使用sprintf()函数,

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

int main ()
{


 int num = 123456;
 char str[50];
 sprintf(str, "%d" , num);
 printf ("The number 'num' is %d and the string 'str' is %s. \n" , num, str);
 getchar();
return 0;
}

posted @ 2012-05-11 19:39  MFT  阅读(175)  评论(0编辑  收藏  举报