我在64位linux上使用sprintf的func.当我测试sprintf或snprintf写的字符串时,会发生奇怪的事情.我用它的方式:
char s[256];
int current=0;
for (int i=0; i<5; i++)
{
current += sprintf(s+current, "d", i);
}
printf("string is %s \n", s);
Run Code Online (Sandbox Code Playgroud)
我得到的是:string是ddddd,如果我将sprintf(s,"d",i)更改为"c"或"lf",我得到的只是ccccc或lflflflflf.有人对此有任何线索吗?非常感谢!