c语言snprintf
In this article, we’ll understand the working and the usage of the snprintf()
C++ function.
在本文中,我们将了解snprintf()
C ++函数的工作和用法。
The snprintf()
function is used to write formatted output to a string. Let’s understand how we can use this function, by showing it’s syntax and giving examples.
snprintf()
函数用于将格式化的输出写入字符串。 通过显示其语法并给出示例,让我们了解如何使用此函数。
C / C ++中snprintf()的基本语法 (Basic Syntax of snprintf() in C/C++)
Since the snprintf()
function will write to a string buffer, it takes a string as an argument, and also a formatted string.
由于snprintf()
函数将写入字符串缓冲区,因此它将字符串作为参数,还有格式化的字符串。
A formatted string is any string that contains format specifiers, like %d
, %c
or %s
. This is similar to printf()
or cout
, except that it will write to a string instead.
格式化的字符串是任何包含格式说明符的字符串,例如%d
, %c
或%s