且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

大厦字符串从C变量

更新时间:2023-02-18 19:37:32

的printf 写到标准输出。 的snprintf 完成你要的东西在这里。内插的字符串被存储在所述调用的snprintf后缓冲。您可能要定义你的缓冲区大小的小更智能,但是这仅仅是一个例子。

printf writes to standard output. snprintf accomplishes what you are going for here. The interpolated string is stored in 'buffer' after the call to snprintf. You may want define your buffer size a little more intelligently, but this is just an example.

char buffer[1024];
snprintf(buffer, sizeof(buffer), "Dealer's Card is %C %C", char1, char2);