描述
C 库函数 int sprintf(char *str, const char *format, …) 发送格式化输出到 str 所指向的字符串。
代码示例
#include <stdio.h>
#include <math.h>
int main()
{
char str[80];
sprintf(str, "Pi的值 = %f", M_PI);
puts(str);
return(0);
}
控制台输出结果:
Pi 的值 = 3.141593