#include <stdio.h>
#include <string.h>
int main()
{
int a = 2;
char str[100];
sprintf(&str[0], "%d", a);
sprintf(&str[1],"%c",str[0]);
printf("str =%s, a = %d,strlen = %ld,str[0] =%c,str[1] =%c\n",\
str,a,strlen(str),str[0],str[1]);
return 0;
}
/** outPut:
*str =22, a = 2,strlen = 2,str[0] =2,str[1] =2*
*/
在gcc 下编译执行的结果。