snprintf 函数用法详解
https://blog.csdn.net/m0_50668851/article/details/110000520
#include “stdio.h”
int main()
{
#define LEN 100
char buf[LEN];
char str1[] = “123”;
int int2 = 456;
char str3[] = “abc”;
float str4 = 3.123456f;
int n = snprintf(buf, LEN, “%s%d%s%f”, str1, int2, str3, str4);
printf(“total length n %d\n”, n);
printf(“buf contex = %s”, buf);
return 0;
}
打印信息:
total length n 17
buf contex = 123456abc3.123456