如何填补C语言文字之间的空白

时间:2019-02-08 19:08:15

标签: c

我有一个文本,我想用C中的数据填充它

char arr[100]="Ahmed %s salah %s is %d";

我要添加数据,而不是%s和%d     成为

arr="Ahmed Elsayed salah Elsenbawy is 16";

1 个答案:

答案 0 :(得分:3)

只需使用sprintf或snprintf。

在这种情况下,使用char *会导致缓冲区溢出。

x